Skip to content

#SqlLastID

VariableSQLRead-onlyNumberNew in Reforged
Set by
SQL, sql Exec

Also searchable as: #SqlLastID · SqlLastID · sql last id · rowid

#SqlLastID is the rowid of the last row inserted through the script tab’s database connection. Use it to link a new row to others, for example in a second table.

sql open :memory:
sql exec CREATE TABLE trips(started INTEGER)
sql exec CREATE TABLE loot(trip INTEGER, item TEXT)
sql exec INSERT INTO trips(started) VALUES(#SysTime)
set %trip #SqlLastID
set %item gold
sql exec INSERT INTO loot(trip, item) VALUES(%trip, %item)
display ok Trip %trip found %item
halt

See also