Skip to content

sql Exec

Sub-commandData (SQL)New in Reforged
sql exec {statement}
Sets
#SqlRes, #SqlChanges, #SqlLastID

Also searchable as: sql Exec

sql exec runs one statement: CREATE, INSERT, UPDATE, DELETE, BEGIN, COMMIT, PRAGMA, … Rows it returns are discarded, and the rows of the last sql query are kept, so you can run sql exec inside a loop over a query’s rows.

The statement is everything after sql exec, exactly as written. %x, !x, #x and *x where a value goes are passed to SQLite as values, never pasted into the text.

sql open mychar.db
sql exec CREATE TABLE IF NOT EXISTS kills(mob TEXT, at INTEGER)
set %mob orc
sql exec INSERT INTO kills(mob, at) VALUES(%mob, #SysTime)
display ok Row #SqlLastID added
halt

Each sql exec that changes data is its own transaction, which is slow for many rows. Wrap a batch in sql exec BEGIN … sql exec COMMIT.

See Using SQL for how statements are written and how variables go in and out.

See also