开发者

Last inserted row with sqlite3 and C

开发者 https://www.devze.com 2023-01-06 14:05 出处:网络
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 querythe function lower(hex(randomblob(16))) g

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.....

0

精彩评论

暂无评论...
验证码 换一张
取 消