How to get rowid when inserting a row into a table

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

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

rowid is an automatic increment.

After inserting the row, I hope to get an array that sqlite generates automatically.

Is it possible?

welcome any comment

thank

+3
source share
2 answers

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

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

+5
source

max (rowid) myTable

0

Source: https://habr.com/ru/post/1769466/


All Articles