SQLite syntax last_insert_rowid()

Someone at - it an example of how last_insert_rowid() works in sqlite with Javascript?

I searched on the web with no luck.

db.transaction(function(tx) {
   tx.executeSql('INSERT INTO myTable (col1,col2) VALUES (?,?)',
      [aValue,bValue],
      function(tx,results) {
         alert('last inserted ROWID: ' + results.insertId);
         //... other work...
      },
      function() { alert('failed insert');});
});

Tags: BlackBerry Developers

Similar Questions

  • SQLite SQL syntax error

    Hello

    This SQL statement generates a DatabaseException in my program:

    Statement sAddCurrentDay = dbScoreKeeper.createStatement ("INSERT INTO METRICS VALUES (?,?,?,?,?,?,?)" ");
    sAddCurrentDay.prepare ();

    The DatabaseException is:

    INSERT INTO METRICS VALUES (?,?,?,?,?,?,?): SQL logic error or missing database

    I'm sure that the database is fine. I have previous statements that operate on the database successfully.

    You can see where there is a SQL logic with my SQL statement error?

    Thank you

    OK, I think that I understand it. The problem was with my education where I created the table.

    Here's the original statement. Can you find the problem?

    Statement sCreate2 = dbScoreKeeper.createStatement ("CREATE TABLE METRICS (DATETIME Long," +)
    "Whole COMP_ONTIME +,
    "Whole COMP_LATE +,
    "Whole COMP_TOTAL +,
    "Whole OPEN_ONTIME +.
    "Whole OPEN_PASTDUE +.
    "(OPEN_TOTAL Integer) ');"

    There are a couple of missing commas there. If the table has only 5 columns, when he must have 7 columns.

    Thank you

  • How to use SQLite temporary tables?

    As read here: http://docs.blackberry.com/en/developers/deliverables/8682/BP_Optimizing_SQLite_database_performance...

    Use temporary tables. Do this only if you do not need data to be available following a reset of the BlackBerry device.

    Read here: http://www.sqlite.org/tempfiles.html

    Tables created using the syntax "CREATE THE TEMP TABLE" is visible only to the connection of database in which the "CREATE TEMP TABLE" statement is initially evaluated.

    The confusing part is that if I create an instance of database for temporary tables with a single statement of DatabaseFactory.open, I am only able to use this same instance of database throughout my entire application?

    So, using the same variable throughout the entire application?

    It also means that I can not close the database connection?

    Here is information on temporary tables of SQLite:

    http://www.SQLite.org/tempfiles.html#tempdb

    (1) you must call 'CREATE TABLE TEMP' every time when you open a database if you need this chart.

    (2) temporary table deleted as soon as you close the database. This means you need to keep the database connection open if you want to run previously inserted/updates of records into a temporary table.

    Thank you

    Eugen

  • SQLite and Images

    Hello world

    I have a problem with Sqlite and the BLOB data type, and Google was not helpful, because I guess that there is no just enough examples yet...

    What I do is the following: I use sqlite to store Images as blobs, as seen here. The table has only two columns, url TEXT and BLOB value

                 connection.begin();
    
                  sql = "INSERT INTO blobs (url, value) VALUES (@a, @b)";               sqlStatement.text = sql;
    
                  for (var i:int = 0, n:int = images.length; i < n; i++)             {                 sqlStatement.parameters["@a"] = images[i].url;                    sqlStatement.parameters["@b"] = images[i].data;                   sqlStatement.execute();                   sqlStatement.clearParameters();               }
    
                  connection.commit();
    

    whereas the images [i] .url are strings, data BitmapData.

    Now the question is: How can I get the image of the BitmapData again? What I'm trying to do is the following

    public function getBlob(url:String = null):Object
            {
                var dp:DataProvider = new DataProvider;
                try {
                    connection.begin(); 
    
                    var sql:String;
    
                    if (url)
                    {
                    sql = "SELECT value FROM blobs WHERE url = @a";
                    sqlStatement.text = sql;
                    sqlStatement.parameters["@a"] = url;
                    }
                    else
                    {
                        sql = "SELECT * FROM blobs";
                        sqlStatement.text = sql;
                    }
                    sqlStatement.execute();
                    sqlStatement.clearParameters();
    
                    var result:SQLResult = sqlStatement.getResult();
                    for each (var obj:Object in result.data){
                        if (obj != null)
                            dp.addItem(obj);
                    }
    
                    connection.commit();
    
                } catch (e:SQLError) {
                    alert.title = "Database Error (" + e.errorID + ")";
                    alert.message = "Error: " + e.message + "\n" + e.details;
                    alert.modalAlpha = 0.1;
                    alert.dialogSize = DialogSize.SIZE_SMALL;
                    alert.addButton("OK");
                    alert.show(IowWindow.getAirWindow().group);
                    connection.rollback();
                    return null;
                }   
    
                return dp;
            }
    

    and

    var dp:DataProvider = getBlob(_newUrl) as DataProvider;
    trace(dp.data[0].value is BitmapData);
    

    but which always returns false: All that it is said that dp.data [0] .value is an object which I can't access

    Any tips?

    This seems to work, using built bitmapData as byteArray, getPixels, setPixels.

    Thank you

    MIke

    package
    {
        import flash.data.SQLConnection;
        import flash.data.SQLResult;
        import flash.data.SQLStatement;
        import flash.display.Bitmap;
        import flash.display.BitmapData;
        import flash.display.Sprite;
        import flash.errors.SQLError;
        import flash.filesystem.File;
        import flash.geom.Rectangle;
        import flash.utils.ByteArray;
    
        [SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
    
        public class SQLBitmapBlob extends Sprite
        {
            private var sqlDatabase:File;
            private var sqlConnection:SQLConnection;
            private var sqlStatement:SQLStatement;
            private var sqlResult:SQLResult;
    
            private static const BITMAP_WIDTH:int = 96;
            private static const BITMAP_HEIGHT:int = 96;
    
            public function SQLBitmapBlob()
            {
                super();
    
                // Init Database
                sqlDatabase = File.applicationStorageDirectory.resolvePath("dbBlob2.db");
                sqlConnection = new SQLConnection();
                sqlConnection.open(sqlDatabase);
                sqlStatement = new SQLStatement();
                sqlStatement.sqlConnection = sqlConnection;
    
                // Create the table if it doesn't exist
                sqlStatement.text = "CREATE TABLE IF NOT EXISTS blob (id INTEGER PRIMARY KEY AUTOINCREMENT, picture BLOB)";
                try{sqlStatement.execute();}
                catch (error:SQLError){trace("SQL STATEMENT: " + sqlStatement.text + "\n Error: " + error.details);}
    
                // Create a random bitmapData
                var bmpData:BitmapData = new BitmapData(BITMAP_WIDTH, BITMAP_HEIGHT, true, 0x000000);
                var bytArray:ByteArray = new ByteArray;
                bmpData.noise(25);
                bytArray.writeBytes(bmpData.getPixels(new Rectangle(0,0, BITMAP_WIDTH, BITMAP_HEIGHT)));
    
                // Save BitmapData to Database
                sqlStatement.text = "INSERT INTO blob (picture) VALUES (@picture)";
                sqlStatement.clearParameters();
                sqlStatement.parameters["@picture"] = bytArray;
                try {sqlStatement.execute();}
                catch (error:SQLError){trace("SQL STATEMENT: " + sqlStatement.text + "\n Error: " + error.details);}
    
                // Preform Select on Database to return row
                var loadedBitmapData:BitmapData = new BitmapData(BITMAP_WIDTH, BITMAP_HEIGHT, true, 0x000000);
                sqlStatement.text = "SELECT * FROM blob WHERE id = last_insert_rowid()";
                sqlStatement.clearParameters();
                try{sqlStatement.execute();}
                catch (error:SQLError){trace("SQL STATEMENT: " + sqlStatement.text + "\n Error: " + error.details);}
    
                // Convert returned data back to bitmapData
                var r:Object = new Object();
                sqlResult = sqlStatement.getResult();
                if (sqlResult.data != null){
                    r = sqlResult.data[0].picture;
                    loadedBitmapData.setPixels(new Rectangle(0,0, BITMAP_WIDTH, BITMAP_HEIGHT), r as ByteArray);
                    trace("Retrievied record id: " + sqlResult.data[0].id + " from db.");
                }
    
                var bmpDisplay:Bitmap = new Bitmap(loadedBitmapData);
                addChild(bmpDisplay);
            }
        }
    }
    
  • SQLite and HTML

    Anyone has any sample code to show how to use a set of HTML construction using the manipulation of the DOM, as in, SQL result using innerHTML?

    Thank you

    Here is the example, I used it on my recent project

    kemasD.getCustomerById = function(id) {    var db = kemasD.webdb.db;
    
        db.transaction(function(tx){        tx.executeSql("SELECT * FROM CUSTOMER WHERE ID = ? ORDER BY ID",              [id],             function(tx, results) {                var buffer = "";
    
                    // results = SQLite result set                if (results.rows && results.rows.length) {                    for ( var i = 0; i < results.rows.length; i++) {                        var current = results.rows.item(i);
    
                            // This part where you want to process the result and wrap it with HTML tag                        buffer += '
    '; buffer += '

    Customer name: ' + current.NAME + '

    '; buffer += '

    Customer address: ' + current.ADDRESS + '

    '; buffer += '

    Customer phone: ' + current.PHONE + '

    '; buffer += '
    '; // Modify the DOM using jQuery (this is the easiest way, AFAIK) // This syntax will insert the 'buffer' inside the
    block // in your page $("div.customer-detail-box").prepend(buffer); buffer = ""; } } }, onErrorHandler); });};

    Hope that this example will help you :))

  • SQLite error in Flex/Air application:

    I'm doing a simple query from inside and demand for Air SQLite:

    Statement.text = 'SELECT Ingredient' +
               'FROM Ingredients'+ 
               'WHERE FoodCatagory_FK = 6'
    

    It works fine when I exicute the query in SQLite Manager, however in the Air, I get the following error:

    SQLError: 'Error #3115: SQL Error.', details:'near 'FoodCatagory_FK': syntax error', operation:'execute', detailID:'2003'
    

    Don't know why it doesn't work, it seems pretty Strait forward.

    Thank you

    Hello

    You must leave a space either after

    Ingredients
    

    or before

    WHERE FoodCatagory_FK
    

    Thank you

    Tamil

  • problem with a update sqlite using variables statement

    Flash Builder/Flex 4

    I am trying to create a routine that will allow me to change the name of an author in an sqlite table.

    I have this update statement that works with hard-coded data:

    trace ("function newAuthorName updateName:" + newAuthorName (Dusty returns));

    trace ("function oldAuthorName updateName:" + oldAuthorName (Kristin returns));

    updateStmt = new SQLStatement();

    updateStmt.sqlConnection = conn;

    var sql:String = "UPDATE tableName SET authorNameColumn = 'Dusty' WHERE authorNameColumn ="Kristin ' ';"

    updateStmt.text = sql;

    updateStmt.execute ();

    If I change the statement to

    "UPDATE tableName SET authorNameColumn =" + newAuthorName + "WHERE authorNameColumn =" + oldAuthorName;

    I get SELECT error: SQLError: ' #3115 error: SQL Error. ", details:' near 'authorNameColumn': syntax error"

    I tried to change a lot about this statement tries to isolate the problem, but it seems to not like variables.

    a better solution would be to use the settings - so you don't have to worry about adding quotes

    See: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/SQLStatement #parameters .html for more details

  • How to find the SQLite database browser on an imac

    Where is the SQLite database browser on an iMac?

    Here, you can get a http://sqlitebrowser.org/

  • URL bar autocomplete works not, renamed file: places.sqlite, now impossible to restore or import bookmarks

    AutoComplete in the bar of my url suddenly stopped working. I use Firefox on a Mac with OS 10.10.5 43.0. First of all, I checked that AutoComplete is enabled in the preferences, "refreshed" Firefox and install a new copy. When none of that worked, I changed the name of the places.sqlite file in my folder of profile, as shown in this thread: https://support.mozilla.org/en-US/questions/951168. It worked and now the url bar autocompletes; Hooray!

    But now my favorites are gone! I supported manually to the top of my favorites in advance, as .html and .json, but when I try to restore/import my favorites of these files, it does not work: I find myself with a bunch of empty folders. Help?

    If you open the HTML export file in a Firefox tab as a web page, should your bookmarks? In other words, is this a problem of import, or was it a problem of export?

  • Syntax error? : = SUMIF(C2:C94,"=10",H2:H94)

    I changed this equation in several different ways and may not have to work. I started by copying directly from a spreadsheet where he worked. Now that I have it on the worksheet on that I need I get syntax errors. I deleted and retyped thinking it was a problem of copy / paste, nothing works. I don't know what I'm doing wrong. This formula has always worked for me. Help, please.

    Hi katxoxo,

    In short, it seems ok to me.

    You could try to do is recreate the formula by clicking and pointing and build these terms by in the Inspector of the formula.

    Quinn

  • Cannot find the overall messages file - db.sqlite

    Hi, volunteers! Thank you for being here.

    The search function of Thunderbird has stopped working. He cannot find all - regardless of the query returned no results.

    I understand that I need to rebuild the global database to correct this and have read the instructions here:

    https://support.Mozilla.org/en-us/KB/rebuilding-global-database

    He tells me to delete my profile from TB global-messages - db.sqlite. Connects me to another page on how to find this profile. I followed these instructions:

    "How to find your profile.

       Click on the menu button or menu bar.
       From the Help menu, click Troubleshooting Information.
       In the Application Basics section, Profile Folder, click on Show in Finder.
       The Mac Finder window will show the name of the profile as well as the path to it."
    

    The finder window shows me this file: zfrnv9to.default - 1445806062498. Nothing inside it looks like the file I'm supposed to delete, which is global-messages - db.sqlite.

    I also used the Mac projector for a search on "global-messages - db.sqlite. He cannot find anything like this on my Mac Air (which is running El Capitan). It is usually pretty reliable to dig up files, but - no luck.

    What should I do now?

    Zenos, thank you! I solved this on my own last night.

    In case it helps the next person: I re-read the page of Mozilla to find the file.

    So, rather than looking in the Application databases, I dug through my files user myself, using the information that it would be under User/Library etc.

    It took a few minutes of poking around to find it. I deleted it, restarted TB, and the search function is back.

    The mystery that I can't solve it is why the recommended method or research Spotlight of the CMA does not find it in the first place. But with time and patience, the manual search does the job.

    Thanks for the tips, the time and help!

  • Regarding the functions of profile file (permissions.sqlite etc..)

    http://KB.mozillazine.org/Profile_folder_-_Firefox

    Permissions.SQLite

    reading - list.sqlite

    Search - metadata.json

    Times.JSON

    Now I know most of them is explained in the article linked above, but not all. I was wondering if anyone knows what each of them and what are the effects of delete them in the process. Since Firefox will delete obsolete/replaced not by / replaced files, I have to do it manually to clean bloating with some versions. That some of them have not been updated in a while or if I have a question its current position to keep it in the folder.

    Research - metadata.json stores data for the search engine as a key word (alias), their order and if they are enabled.

    You can open JSON files in Notepad (Firefox Tools menu button > Web Developer) for the purpose of inspection.
    Click on the button to "Pretty Print" to fit the file for readability.

    You can use the SQLite Manager extension in Firefox to inspect the SQLite database files.

    Permissions.SQLite stores the specific site (site preferences) permissions as you can see by his name.

    You can control and manage permissions for the domain in the tab currently selected through these steps:

    • Click the address bar onthe Site identity button"(globe/lock)
    • Click on 'More information' to open ' tools > Page Info "with the Security tab is selected

    Go to the permissions tab (Tools > Page Info > permissions) to check the permissions for the domain in the currently selected tab.

  • How can I import my old passwords of key3.db key3 and files for the new firefox signons.sqlite 41.0?

    I recently updated my PC and my old hard drive in system is placed as a slave in my new PC. Seen key3 and signons.sqlite key3.db files of the old firefox, how to import passwords saved in the new firefox 41.0?

    Thank you.

    How old was the older Firefox? Firefox 33 and then use this pair of files:

    • logins. JSON -. saved passwords.
    • signons3.txt - this file stores your database key for your passwords.

    If you want to move the old in your current profile (to replace new empty files for the most part), this is the fastest way to open your folder of the currently active profile. Either:

    • button "3-bar" menu > "?" button > troubleshooting information
    • (menu bar) Help > troubleshooting information
    • type or paste everything: in the address bar and press Enter

    In the first table of the page, click on the view file"" button. This should launch a new window that lists the various files and folders in Windows Explorer.

    Leave this window open, switch back to Firefox and output, either:

    • "3-bar" menu button > button "power".
    • (menu bar) File > Exit

    Pause while Firefox finishing its cleanup, then rename logins.json to something like logins.old and key3db to something like key3.old.

    Now copy the old two files in this folder.

    Launch Firefox back up again. These connections are available?

  • Firefox does not start after the places.sqlite opening in Notepad

    Firefox does not load again. I tried to create a large folder of bookmarks, but I wanted them to hide so I tried to be clever and create a copy of my current places.sqlite who had no bookmarks added and moved elsewhere, then I added bookmarks and once that replace the current places.sqlite then I created a copy of this and put it elsewhere for more security and then I replaced it with the first places.sqlite I had copied. I had to go through that much trouble because for reasons, I was unable to delete the bookmarks by right-clicking and selecting delete. I had already tried to open places.sqlite in Notepad and since then is when it started to happen. I tried to reset the file extension type, or rather detached, but I can't figure out how. I also tried to remove completely any Mozilla partner, restarted my computer and then reinstall Mozilla, but it didn't work and I prefer not to try again or uninstall it because my computer has a very difficult time even boot Windows 10. He likes to get on the desktop and then never hang while I have to restart the computer continuously until it works.

    Can someone tell me what to do or where it is that I was wrong?

    Do a clean reinstall and delete the program folder before Firefox to (re) install a new copy of the current version of Firefox.

    If possible to uninstall your current version of Firefox to clean the Windows registry and settings in the security software.

    • Do NOT remove the "personal data" when you uninstall your current version of Firefox, because this will remove all profile folders and you lose personal data such as bookmarks and passwords including data profiles created by other versions of Firefox.

    Delete the program folder Firefox before installing newly downloaded copy of the Firefox installer.

    • (32-bit Windows) "C:\Program Files\Mozilla Firefox\"
    • (Windows 64 bit) "C:\Program Files (x 86) \Mozilla.

    Your bookmarks and other personal data are stored in the Firefox profile folder and will not be affected by a uninstall and (re) install, but do NOT delete personal data when you uninstall Firefox which removes all Firefox profile folders and you lose your data.

    If you keep the problems, and then create a new profile.

  • How to restore passwords signons3.txt? And how works signons.sqlite?

    I had to restore my operating system. I could get places.sqlite to restore the bookmarks (good!). I could find a signons3.txt (dated July 2013) this file will be not complete or up to date, but at least it puts me somewhere before.

    I have read that I need a signon3.txt file to go with the key3. I don't have one. I found a file dated September 2014 signons.sqlite. I moved these two files in my profiles folder, but I don't fit my old password.

    Is it possible for me to use the old key3? Do the key3 and sign must be dated the same thing? Is it possible to recreate the signons.txt?

    I have the password.

    Thanks for help.

    Signons3.txt file store the encryption key used to encrypt and decrypt passwords.
    Encrypted names and passwords are stored in the logins.json file.
    The file signons.sqlite is no longer used in current versions since Firefox 32.

    You must move the logins.json and key3db files in the current profile folder to retrieve passwords.

Maybe you are looking for

  • Wireless switch doesn't seem to work on the Satellite M35X-S114

    I have a Satellite M35X-S114. OS is XP SP2. I use wireless at home for years. Yesterday, my laptop started telling me that it couldn't find my router and my wireless radio switch was not turned on. As it's turned on and orange glowing like always. I

  • FS: Sony F55 complete shooting Kit

    Hello, unfortunetly gear I'm ready to sell my Sony F55 shooting Kit including the following: 1 x camera of Sony F55 1 x recorder Raw Sony R5 3 x 512 GB AVXM cards 1 x OLED Sony EL100 viewfinder 1 x Kit of LWS ARRI including BP8 1 x Solidcamera Scatte

  • LabVIEW Ridge detector - fails the simple test?

    Hi people. I tried two different spectra for the LabVIEW waveform peak detector (LabVIEW 8.5).  It works fine, the other not, and I'm trying to understand why.  VI and attached screenshot.  I've hardcoded the bays so you can just run the VI.  Any tho

  • Upgrade T1i or continue?

    I own a Canon T1i and really like it. A month ago, I bought a lens wide angle.  The seller told me that the lens doesn't work, but because the camera was old, I'd get all the features.  So I wonder if I should buy a new camera instead of investing mo

  • Copied elements appear in the Clipboard for 5 seconds and then disappears

    PC running Windows XP SP3. I tried to scan the computer from viruses and malware using a variety of software. When I copy something (ctrl-c), the item remains in the Clipboard for about 5 seconds and then disappears. I can paste the item within 5 sec