TableName | Name of table to get last id of. |
There is also the similar command dbcmd onecolumn sql
in the SQLite package.
Check this page for info about how to set up Gen for using database-related commands.
This code: (1) Creates a table and puts a record in it, (2) Shows that LastId returns 1, (3) Adds another entry to the table, (4) Shows that LastId now returns 2.
% RunSqlCreate my_table {id {integer primary key} desc text notes text}
% QQ [SqlInsertStatement my_table {desc 'one' notes 'uno'}]
% LastId my_table
1
% QQ "INSERT INTO my_table (desc) VALUES ('two')"
% LastId my_table
2