world.DatabaseFinalize
Finalizes (wraps up) a previously-prepared SQL statement
Prototype
long DatabaseFinalize(BSTR DbName);
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
See also
| Function | Description |
|---|---|
| DatabaseColumnName | Find the name of a specified column returned by an SQL statement |
| DatabaseColumnNames | Return a table of all the columns returned by an SQL statement |
| DatabaseColumnText | Returns the contents of an SQL column, as text |
| DatabaseColumnType | Returns the type of data in an SQL column |
| DatabaseColumnValue | Returns the contents of an SQL column, as text, float, integer, or null |
| DatabaseColumnValues | Returns the contents of all the SQL columns after a step |
| DatabaseColumns | Find how many columns will be returned by an SQL statement |
| DatabaseError | Returns an English string describing the most recent SQL error |
| DatabaseExec | Executes SQL code against an SQLite database |
| DatabaseLastInsertRowid | Returns the most recently automatically allocated database key |
| DatabaseOpen | Opens an SQLite database |
| DatabasePrepare | Prepares an SQL statement for execution |
| DatabaseReset | Resets a previously-prepared SQL statement to the start |
| DatabaseStep | Executes a previously-prepared SQL statement |