facebook

Asynchronous DB trnsactions?

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #331897 Reply

    RossL321
    Member

    Hi guys,
    I have been created a local DB with one table and one row.
    All is well until I try to select from it.
    I use the following code:

    function CheckForRow() {
        //Select the last (and hopefully only) row
        var query = "SELECT * FROM " + window.myTable + ";";
        window.db.transaction(function(tx) {
            tx.executeSql(query, [], DataHandler, Error);
        });
            //I want to test my result data here, but the data handler hasn't been invoked yet! 
    }
    
    function DataHandler(tx, resultSet){
        for (var i = 0; i < resultSet.rows.length; i++) {
                var row = resultSet.rows.item(i);
                window.myName = row['name'];
                window.myData = row['data'];
        }
    }

    What I am finding is that the handle function for the result data isn’t invoked until after the procedure that calls CheckForRow completes.
    Does this mean that you can only effectively run asynch calls, or am I barking up the wrong tree? That would make for me a whole load of trouble!

    regards
    Ross

    #332143

    Hi Ross,

    I’ve been reviewing at this issue these last days, and have not found anything useful yet. I’m not sure if is possible, could you tell us what are your requirements to see if we can find another approach for this?

    #332176

    support-michael
    Keymaster

    >Does this mean that you can only effectively run asynch calls,

    Yes, the web db api is asynchronous. See the spec http://www.w3.org/TR/webdatabase/#asynchronous-database-api
    Note: web db has been deprecated but is still supported on iOS and android.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Asynchronous DB trnsactions?

You must be logged in to post in the forum log in