Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get row id for inserted row in sqldelight

I'm trying to use sqldelight to insert an item, but to also return the id of the item after it's inserted. There doesn't seem to be a way to do this in sqldelight.

I can call something like SELECT last_insert_rowid(); after I do the insert, but is this the best way to move forward?

like image 462
spierce7 Avatar asked Dec 10 '18 15:12

spierce7


1 Answers

You can add this command to your .sq file:

lastInsertRowId:
SELECT last_insert_rowid()
;

And it will return you an id of last inserted row.

Please refer to this issue on Github for more info.

like image 126
snitsaruk Avatar answered Oct 29 '22 20:10

snitsaruk