views:

35

answers:

2

Hi folks,

I wrote a kind of key/value store using sqlite3 and C. my put_pair(key, value) function accepts an empty key as a correct key, and in my INSERT query I use lower(hex(randomblob(16))) to generate a good key for this inserted row.

The problem now is how to retrieve this key and return it by my function?

A: 

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.

vpit3833
Thanks vpit3833! I actually thought of rowid too, but that'd require another SELECT query after the INSERT one just to grab the key. And I'd like to run only one query per insert. I guess I should write a little uuid function or use a simple existing one. Thanks again!
sandra
+1  A: 

You can use sqlite3_last_insert_rowid

Brian R. Bondy
Thanks Brian, like I said to vpit3833 below, I'd still need a SELECT to grab that key, and I need only one query per insert
sandra