NAME
LastId — Find last id in the table and return it.
SYNOPSIS
LastId TableName
DESCRIPTION
Return Value
The last id in the given table.
Arguments
TableNameName of table to get last id of.
More Info
Note that this command returns the last ID in terms of order. This is usually also the last ID entered. Note also this command assumes the name of the column is "id".

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.


For information regarding exceptions / errors, see here.
EXAMPLES

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
KEYWORDS
sql