Register forum user name Search FAQ

MUSHclient scripting

Description of MUSHclient world function: world.DatabaseFinalize


Name DatabaseFinalize
Type Method
Summary 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.


Note: Available in version 4.40 onwards.


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
Returns 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
Introduced in version 4.40

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
DatabaseColumns Find how many columns will be 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
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

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.


Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes


Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes


View all functions

[Back]

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.