10

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?

spierce7
  • 14,797
  • 13
  • 65
  • 106

1 Answers1

12

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.

snitsaruk
  • 422
  • 6
  • 13