world.DatabaseFinalize

MUSHclient script function (Method) — introduced in version 4.40

Finalizes (wraps up) a previously-prepared SQL statement

Prototype

long DatabaseFinalize(BSTR DbName);

Data type meanings

Description

This must be called after calling DatabasePrepare, once you have finished with the current SQL statement. You will not be able to call DatabasePrepare again, until the first one is finalized.

Lua example

-- insert a record
DatabasePrepare ("db", "INSERT INTO weapons (name, damage) VALUES ('sword', 42)")  --> returns 0 (sqlite3.OK)
DatabaseStep ("db")   -- returns 101 (sqlite3.DONE)
DatabaseFinalize ("db")  -- returns 0 (sqlite3.OK)

Lua notes

The return codes are available in the sqlite3 table in Lua, as follows:

sqlite3.OK = 0
sqlite3.INTEGER = 1
sqlite3.INTERNAL = 2
sqlite3.PERM = 3
sqlite3.ABORT = 4
sqlite3.BUSY = 5
sqlite3.LOCKED = 6
sqlite3.NOMEM = 7
sqlite3.READONLY = 8
sqlite3.INTERRUPT = 9
sqlite3.IOERR = 10
sqlite3.CORRUPT = 11
sqlite3.NOTFOUND = 12
sqlite3.FULL = 13
sqlite3.CANTOPEN = 14
sqlite3.PROTOCOL = 15
sqlite3.EMPTY = 16
sqlite3.SCHEMA = 17
sqlite3.TOOBIG = 18
sqlite3.CONSTRAINT = 19
sqlite3.MISMATCH = 20
sqlite3.MISUSE = 21
sqlite3.NOLFS = 22
sqlite3.FORMAT = 24
sqlite3.RANGE = 25
sqlite3.NOTADB = 26
sqlite3.ROW = 100
sqlite3.DONE = 101

Return value

0: Completed OK

-1 : Database id not found
-2 : Database not open
-4 : Do not have prepared statement

Otherwise an SQLite return code. For example:

1: SQL error or missing database
5 : The database file is locked
21 : Library used incorrectly

Related topic

Database (SQLite)

See also

FunctionDescription
DatabaseColumnNameFind the name of a specified column returned by an SQL statement
DatabaseColumnNamesReturn a table of all the columns returned by an SQL statement
DatabaseColumnTextReturns the contents of an SQL column, as text
DatabaseColumnTypeReturns the type of data in an SQL column
DatabaseColumnValueReturns the contents of an SQL column, as text, float, integer, or null
DatabaseColumnValuesReturns the contents of all the SQL columns after a step
DatabaseColumnsFind how many columns will be returned by an SQL statement
DatabaseErrorReturns an English string describing the most recent SQL error
DatabaseExecExecutes SQL code against an SQLite database
DatabaseLastInsertRowidReturns the most recently automatically allocated database key
DatabaseOpenOpens an SQLite database
DatabasePreparePrepares an SQL statement for execution
DatabaseResetResets a previously-prepared SQL statement to the start
DatabaseStepExecutes a previously-prepared SQL statement