sqlite.Statement
generated from ../src/mod_sqlite/stmt.cppImplements an sqlite statement. Use the prepare method to create a SQLite SQL statement.
Constants
Properties
| Name | Type | Description |
|---|---|---|
columnCount ![]() |
Integer | Return the number of columns in the result set returned by the prepared SQL statement. |
Methods
bind
bind(Parameter,
Value) : Integer
| Name | Type | Default | Description |
|---|---|---|---|
| Parameter | Integer | Number of parameter (index starts at 1) | |
| Value | Mixed | The value to bind |
bind(Parameter,
Value) : Integer
| Name | Type | Default | Description |
|---|---|---|---|
| Parameter | String | The name of the parameter | |
| Value | Mixed | The value to bind |
In the SQL strings input to prepare, one or more literals
can be replace by a parameter "?" or ":AAA" or "$VVV" where AAA is an
alphanumeric identifier and VVV is a variable name according to the syntax
rules of the TCL programming language. The values of these parameters
(also called "host parameter names") can be set using bind.
The first argument to bind is the index or the name of the parameter
to be set. The first parameter has an index of 1.
The second argument is the value to bind to the parameter.
bind must be called after prepare or
reset and before sqlite3_step(). Bindings are not
cleared by the reset.
Unbound parameters are interpreted as NULL.
bind returns SQLite.OK on success or an error code if anything goes wrong.
SQLite.RANGE is returned if the parameter index is out of range.
SQLite.NOMEM is returned if malloc fails. SQLite.MISUSE is returned
if these routines are called on a virtual machine that is the wrong state
or which has already been finalized.
Blobs are supported. Use a wxMemoryBuffer instance as value.
columnDeclType
columnDeclType(Column) : String
| Name | Type | Default | Description |
|---|---|---|---|
| Column | Integer | The number of the column |
The declared type of the table column is returned. If the column of the result set is not a table column, then null is returned. For example, in the database schema:
CREATE TABLE t1(c1 INTEGER);And the following statement compiled:
SELECT c1 + 1, c1 FROM t1;Then this method would return the string "INTEGER" for the second result column (Column==1), and nullL for the first result column (Column==0).
If the following statements were compiled then this method would return "INTEGER" for the first (only) result column.
SELECT (SELECT c1) FROM t1; SELECT (SELECT c1 FROM t1); SELECT c1 FROM (SELECT c1 FROM t1); SELECT * FROM (SELECT c1 FROM t1); SELECT * FROM (SELECT * FROM t1);
columnName
columnName(Column) : String
| Name | Type | Default | Description |
|---|---|---|---|
| Column | Integer | The number of the column |
This function returns the column heading for the column of this statement,
columnOriginalName
columnOriginalName(Column) : String
| Name | Type | Default | Description |
|---|---|---|---|
| Column | Integer | The number of the column |
If the column returned by the statement is a column reference, this function may be used to access the schema name of the referenced column in the database schema. If the column is not a column reference, NULL is returned.
columnTableName
columnTableName(Column) : String
| Name | Type | Default | Description |
|---|---|---|---|
| Column | Integer | The number of the column |
If the column returned by the statement is a column reference, this function may be used to access the name of the table that contains the column. If the column is not a column reference, null is returned.
fetchArray
fetchArray() : Array
This method calls step and returns the row in an array. An empty array will be returned when no rows are available anymore.
fetchObject
fetchObject() : Object
This method calls step and returns the row as a JavaScript object. null will be returned when no rows are available anymore.
reset
reset() : Integer
The reset function is called to reset a prepared SQL statement obtained by a previous call to prepare back to it's initial state, ready to be re-executed.
step
step() : Integer
After an SQL query has been prepared with a call to either prepare, then this method must be called one or more times to execute the statement. The return value will be either SQLite.BUSY, SQLite.DONE, SQLite.ROW, SQLite.ERROR, or SQLite.MISUSE.
- SQLite.BUSY means that the database engine attempted to open a locked database and there is no busy callback registered. Call step again to retry the open.
- SQLite.DONE means that the statement has finished executing successfully. step should not be called again on this virtual machine without first calling reset to reset the virtual machine back to its initial state.
- If the SQL statement being executed returns any data, then SQLite.ROW is returned each time a new row of data is ready for processing by the caller. Call step again to retrieve the next row of data.
- SQLite.ERROR means that a run-time error (such as a constraint violation) has occurred. step should not be called again on the VM. More information may be found in the property errmsg.
-
SQLite.MISUSE means that the this routine was called inappropriately.
Perhaps it was called on a virtual machine that had already been
finalized or on one that had previously returned SQLite.ERROR or
SQLite.DONE. Or it could be the case that a database connection is being
used by a different thread than the one it was created it.
SQLite.MISUSE is also returned when the associated SQLiteDatabase object is not available anymore. This can occur when the SQLiteDatabase is finalized (when the variable gets out of scope for example). Make sure the SQLiteDatabase object is still referenced somewhere by a local or global variable.

© 2002 - 2007 Franky Braem.