Last inserted row with sqlite3 and C
I wrote a key/value
store using SQLite3
and C
. The function put_pair(key, value)
accepts a开发者_开发知识库n empty key as a correct key and in the INSERT
query the function lower(hex(randomblob(16)))
generates a good key for this inserted row.
But I don't know how to retrieve this key and return it by my function.
Any suggestions?
You can use sqlite3_last_insert_rowid
When the key is not known, try searching by values that match the given condition and return the rows. Or if it is just the most recently inserted row that you are after, look at this page.
Query goes like this :
select * from emp where rowid = (select max(rowid) from emp);
emp = my table name
Hope will help needy ppl.....
精彩评论