sqlite3_bind
| Definition: |
include pSQLite.e
integer ret = sqlite3_bind_parameter_count(sqlite3_stmt pStmt) -- or -- integer ret = sqlite3_bind_parameter_index(sqlite3_stmt pStmt, string zName) -- or -- string res = sqlite3_bind_parameter_name(sqlite3_stmt pStmt, integer idx) -- and -- sqlite3_bind_int(sqlite3_stmt pStmt, atom_string idx, integer val) -- or -- sqlite3_bind_double(sqlite3_stmt pStmt, atom_string idx, atom val) -- or -- sqlite3_bind_text(sqlite3_stmt pStmt, atom_string idx, string val) -- or -- sqlite3_bind_blob(sqlite3_stmt pStmt, atom_string idx, object val) -- or -- sqlite3_bind_null(sqlite3_stmt pStmt, atom_string idx) |
| Description: |
The sqlite3_bind routines are used to assign values to wildcards in a prepared SQL statement.
In the SQL strings input to sqlite3_prepare(), one or more fields can be a wildcard "?" or "?nnn" or ":nnn:" or ":AAA", where AAA is an alphanumeric identifier. The value of these wildcard literals (also called "host parameter names") can be set using these routines. pStmt: A pointer to the sqlite3_stmt structure returned from sqlite3_prepare(). zName: an alphanumeric identifier (AAA above, UTF-8 encoded) idx: the index of the wildcard, invokes sqlite3_bind_parameter_index() on strings. The first wildcard has an index of 1. val: the integer/atom/string/object value to assign to the specified wildcard. The sqlite3_bind_*() routines must be called after sqlite3_prepare() or sqlite3_reset() and before sqlite3_step(). Bindings are not reset by sqlite3_reset() - ie you are not forced to re-write the same value every time, but wildcards can be rebound to new values after an sqlite3_reset(). Unbound wildcards are interpreted as NULL. Returns: sqlite3_bind_parameter_count() returns the number of wildcards in the precompiled statement given as the argument. sqlite3_bind_parameter_index() returns the index of the wildcard with the given name. The name must match exactly. If there is no wildcard with the given name, returns 0. sqlite3_bind_parameter_name() returns the name of the n-th wildcard in the precompiled statement. Wildcards of the form ":AAA" have a name which is the string ":AAA". Wildcards of the form "?" or "?NNN" have no name, "" is returned, ditto if idx out of range. sqlite3_bind_int(), sqlite3_bind_double(), sqlite3_bind_text(), sqlite3_bind_blob(), and sqlite3_bind_null() do not return a value. After all wildcards have been appropriately assigned, the statement can be executed using sqlite3_step(pStmt). |
| pwa/p2js: | Not supported |
| Comments: |
The sqlite3_bind_blob() routine uses serialize(val), and sqlite3_column_blob()
uses deserialize() to retrieve it. Use sqlite3_bind_null() to explicitly unset a wildcard, when needed in a loop, since sqlite3_reset() does not. Internally, these routines rely on SQLITE_TRANSIENT, so that SQLite makes its own private copy of any data. Note that sqlite3_bind_text() does not have to worry about quotation marks etc in the text, and similarly but internally with sqlite3_bind_blob(), whereas that could be an issue for sqlite3_exec() and sqlite3_get_table(). |
| Example: | See sqlite3_prepare |