[sqlite] Using last_row_insert() with sqlite3_prepare() and friends.

2012-01-18 Thread g...@novadsp.com
Using SQLite version 3.7.7.1 (Windows/VS2008). A table has an integer autoincrement primary key, the value of which is being used to feed an R*Tree index. I am attempting to insert data and retrieve the latest row_id() in a compound statement like this using the SQLite C API: "INSERT INTO ta

Re: [sqlite] Using last_row_insert() with sqlite3_prepare() and friends.

2012-01-18 Thread Petite Abeille
On Jan 18, 2012, at 3:35 PM, g...@novadsp.com wrote: > "INSERT INTO table (columns) VALUES(?,?,?,?); > SELECT last_insert_rowid() FROM table;" These are really two statements, not one. Execute them one after the other and you will get the desired effect. __

Re: [sqlite] Using last_row_insert() with sqlite3_prepare() and friends.

2012-01-18 Thread Igor Tandetnik
g...@novadsp.com wrote: > "INSERT INTO table (columns) VALUES(?,?,?,?); SELECT last_insert_rowid() > FROM table;" > > which works in the Sqlite3 console. However when I run this > sqlite3_step() returns SQLITE_DONE. > > sqlite3_prepare(); > sqlite3_bind_xxx(); > sqlite3_step(); > > Can anyone po

Re: [sqlite] Using last_row_insert() with sqlite3_prepare() and friends.

2012-01-18 Thread g...@novadsp.com
Thanks to all. On 18/01/2012 14:53, Petite Abeille wrote: Or just use last_insert_rowid() directly in the next insert statement. That will reuse the rowid of the previous insert for the new one. And both row will end up with the same id, keeping your source table and its R*Tree index in syn

Re: [sqlite] Using last_row_insert() with sqlite3_prepare() and friends.

2012-01-18 Thread Petite Abeille
On Jan 18, 2012, at 4:16 PM, g...@novadsp.com wrote: >> Or just use last_insert_rowid() directly in the next insert statement. That >> will reuse the rowid of the previous insert for the new one. And both row >> will end up with the same id, keeping your source table and its R*Tree index >> in