tags:

views:

59

answers:

2

Hello everyone

I hope to add a row to a table in a sqlite database.

[NSString stringWithFormat:@"INSERT INTO myTable (rowid,myName ) VALUES (NULL, '%@');" , [aInfo myString]];

rowid is auto increment.

After insert the row, I hope to get the rowid that generate by sqlite automatically.

Is it possible?

welcome any comment

Thanks

+3  A: 

You can get the new generated id with the last_insert_rowid() function. See http://www.sqlite.org/c3ref/last_insert_rowid.html

You do not say what language are you using, but search in your SQLite library implementation for last_insert_rowid function...

caligari
caligari: The code snippet in the question is in Objective-C.
Peter Hosey
A: 

you can use select max(rowid) from myTable

Sheetal Inani