Hi
What is the difference of using last_insert_row() in a Javascript
function vs. using it in DB Query Tool?
I have created a table in Google Gears (Sqlite):
db.execute('create table if not exists SPALINKS (link_id int PRIMARY
KEY, sid1 int, sid2 int, label text, user text, Timestamp int');
When using the Google Gears Database Query Tool (in FF 3.5), INSERT
with 'last_insert_rowid()' works fine. Inserts from Javascript work
fine, as long a I don't use 'last_insert_rowid()'. But when using
'last_insert_rowid()' it doesn't work anymore:
var sql_stmt = 'INSERT INTO SPALINKS (link_id, sid1, sid2, label,
user, Timestamp) VALUES (last_insert_rowid(),?,?,?,?,?)';
var arg_array = [sid1, sid2, label, user, creation_time];
db.execute(sql_stmt, arg_array);
this results in:
Error: Database operation failed. ERROR: constraint failed DETAILS:
constraint failed
Why does SQLite's 'last-insert-rowid' work fine with the DB Tool, but
not in a SQL statement that is created and executed from inside a
Javascript function?
Note: this post is the same as the one here:
http://stackoverflow.com/questions/1249365/difference-when-using-lastinsertrow-in-javascript-function-vs-in-db-query-to
-Roman