0

I have this code:

database.transaction(function(transaction) {
    transaction.executeSql('INSERT INTO incomplete (todo, description, date) VALUES (?, ?, ?);', [todoInput, descriptionInput, myDate]);
});

But what I want to do is to get the row[]; (or more specifically row[id]) from what I just inserted.

Does the transaction method return any more values?

UPDATE:

I inserted it with variables, standard sqlite-webapp way.

    var todoInput = $('#todo').val();
    var descriptionInput = $('#description').val();
    var myDate = new Date();
    myDate.getMonth() + 1 + '/' + myDate.getDate() + '/' + myDate.getFullYear();

    database.transaction(function(transaction) {
        transaction.executeSql('INSERT INTO incomplete (todo, description, date) VALUES (?, ?, ?);', [todoInput, descriptionInput, myDate]);
    });
Joakim Engstrom
  • 6,243
  • 12
  • 48
  • 67

1 Answers1

0

you need to return the id straight after your insert.

add this ;select scope_identity() to your query.

then you should be able to pull out the id of the inserted row and do what you want from there.

Joseph Le Brech
  • 6,541
  • 11
  • 49
  • 84
  • select scope_identity() is not supported with sqlite, but you might have pointed me in the right direction: http://stackoverflow.com/questions/5841921/how-to-use-scope-identity-in-sqlite – Joakim Engstrom Dec 09 '11 at 12:13