Reputation: 63
Created the following code in SQL however need to use it in sqlite (phonegap specifically).
INSERT INTO actions(Action) VALUES ('Go to the pub');
SET @aid = LAST_INSERT_ID();
INSERT INTO statements(statement, Language) VALUES ('Have a pint', 'English');
SET @sid = LAST_INSERT_ID();
INSERT INTO Relationships(SID,AID) VALUES (@sid,@aid);
The issue we are having however is how to declare the variables in sqlite.
The LAST_INSERT_ID() will become last_insert_rowid(), however what is the sqlite version of SET @aid = ?
Upvotes: 2
Views: 658
Reputation: 180060
SQLite does not have variables.
In an embedded database such as SQLite, there is no separate server machine or even process, so it would not make sense to add a programming language to the DB engine when the same control flow and processing logic could be just as well done in the application itself.
Just use three separate INSERT
statements.
(In WebSQL, the result object has the insertId
property.)
Upvotes: 1