Last inserted row with sqlite3 and C

懵懂的女人 提交于 2019-12-11 16:05:53

问题


I wrote a key/value store using SQLite3 and C. The function put_pair(key, value) accepts an 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?


回答1:


You can use sqlite3_last_insert_rowid




回答2:


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.




回答3:


Query goes like this :

select * from emp where rowid = (select max(rowid) from emp);

emp = my table name

Hope will help needy ppl.....



来源:https://stackoverflow.com/questions/3199946/last-inserted-row-with-sqlite3-and-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!