📄 sqlite3.h
字号:
/*** CAPI3REF: Name Of A Host Parameter**** This routine returns a pointer to the name of the n-th parameter in a ** [sqlite3_stmt | prepared statement].** Host parameters of the form ":AAA" or "@AAA" or "$VVV" have a name** which is the string ":AAA" or "@AAA" or "$VVV". ** In other words, the initial ":" or "$" or "@"** is included as part of the name.** Parameters of the form "?" or "?NNN" have no name.**** The first bound parameter has an index of 1, not 0.**** If the value n is out of range or if the n-th parameter is nameless,** then NULL is returned. The returned string is always in the** UTF-8 encoding even if the named parameter was originally specified** as UTF-16 in [sqlite3_prepare16()] or [sqlite3_prepare16_v2()].*/const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);/*** CAPI3REF: Index Of A Parameter With A Given Name**** This routine returns the index of a host parameter with the given name.** The name must match exactly. If no parameter with the given name is ** found, return 0. Parameter names must be UTF8.*/int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);/*** CAPI3REF: Reset All Bindings On A Prepared Statement**** Contrary to the intuition of many, [sqlite3_reset()] does not** reset the [sqlite3_bind_blob | bindings] on a ** [sqlite3_stmt | prepared statement]. Use this routine to** reset all host parameters to NULL.*/int sqlite3_clear_bindings(sqlite3_stmt*);/*** CAPI3REF: Number Of Columns In A Result Set**** Return the number of columns in the result set returned by the ** [sqlite3_stmt | compiled SQL statement]. This routine returns 0** if pStmt is an SQL statement that does not return data (for ** example an UPDATE).*/int sqlite3_column_count(sqlite3_stmt *pStmt);/*** CAPI3REF: Column Names In A Result Set**** These routines return the name assigned to a particular column** in the result set of a SELECT statement. The sqlite3_column_name()** interface returns a pointer to a UTF8 string and sqlite3_column_name16()** returns a pointer to a UTF16 string. The first parameter is the** [sqlite_stmt | prepared statement] that implements the SELECT statement.** The second parameter is the column number. The left-most column is** number 0.**** The returned string pointer is valid until either the ** [sqlite_stmt | prepared statement] is destroyed by [sqlite3_finalize()]** or until the next call sqlite3_column_name() or sqlite3_column_name16()** on the same column.*/const char *sqlite3_column_name(sqlite3_stmt*, int N);const void *sqlite3_column_name16(sqlite3_stmt*, int N);/*** CAPI3REF: Source Of Data In A Query Result**** These routines provide a means to determine what column of what** table in which database a result of a SELECT statement comes from.** The name of the database or table or column can be returned as** either a UTF8 or UTF16 string. The returned string is valid until** the [sqlite3_stmt | prepared statement] is destroyed using** [sqlite3_finalize()] or until the same information is requested** again about the same column.**** The first argument to the following calls is a ** [sqlite3_stmt | compiled SQL statement].** These functions return information about the Nth column returned by ** the statement, where N is the second function argument.**** If the Nth column returned by the statement is an expression** or subquery and is not a column value, then all of these functions** return NULL. Otherwise, they return the ** name of the attached database, table and column that query result** column was extracted from.**** As with all other SQLite APIs, those postfixed with "16" return UTF-16** encoded strings, the other functions return UTF-8.**** These APIs are only available if the library was compiled with the ** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.*/const char *sqlite3_column_database_name(sqlite3_stmt*,int);const void *sqlite3_column_database_name16(sqlite3_stmt*,int);const char *sqlite3_column_table_name(sqlite3_stmt*,int);const void *sqlite3_column_table_name16(sqlite3_stmt*,int);const char *sqlite3_column_origin_name(sqlite3_stmt*,int);const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);/*** CAPI3REF: Declared Datatype Of A Query Result**** The first parameter is a [sqlite3_stmt | compiled SQL statement]. ** If this statement is a SELECT statement and the Nth column of the ** returned result set of that SELECT is a table column (not an** expression or subquery) then the declared type of the table** column is returned. If the Nth column of the result set is an** expression or subquery, then a NULL pointer is returned.** The returned string is always UTF-8 encoded. For example, in** the database schema:**** CREATE TABLE t1(c1 VARIANT);**** And the following statement compiled:**** SELECT c1 + 1, c1 FROM t1;**** Then this routine would return the string "VARIANT" for the second** result column (i==1), and a NULL pointer for the first result column** (i==0).**** SQLite uses dynamic run-time typing. So just because a column** is declared to contain a particular type does not mean that the** data stored in that column is of the declared type. SQLite is** strongly typed, but the typing is dynamic not static. Type** is associated with individual values, not with the containers** used to hold those values.*/const char *sqlite3_column_decltype(sqlite3_stmt *, int i);const void *sqlite3_column_decltype16(sqlite3_stmt*,int);/* ** CAPI3REF: Evaluate An SQL Statement**** After an [sqlite3_stmt | SQL statement] has been prepared with a call** to either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or to one of** the legacy interfaces [sqlite3_prepare()] or [sqlite3_prepare16()],** then this function must be called one or more times to evaluate the ** statement.**** The details of the behavior of this sqlite3_step() interface depend** on whether the statement was prepared using the newer "v2" interface** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the** new "v2" interface is recommended for new applications but the legacy** interface will continue to be supported.**** In the lagacy interface, the return value will be either [SQLITE_BUSY], ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].** With the "v2" interface, any of the other [SQLITE_OK | result code]** or [SQLITE_IOERR_READ | extended result code] might be returned as** well.**** [SQLITE_BUSY] means that the database engine was unable to acquire the** database locks it needs to do its job. If the statement is a COMMIT** or occurs outside of an explicit transaction, then you can retry the** statement. If the statement is not a COMMIT and occurs within a** explicit transaction then you should rollback the transaction before** continuing.**** [SQLITE_DONE] means that the statement has finished executing** successfully. sqlite3_step() should not be called again on this virtual** machine without first calling [sqlite3_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. The values may be accessed using** the [sqlite3_column_int | column access functions].** sqlite3_step() is called again to retrieve the next row of data.** ** [SQLITE_ERROR] means that a run-time error (such as a constraint** violation) has occurred. sqlite3_step() should not be called again on** the VM. More information may be found by calling [sqlite3_errmsg()].** With the legacy interface, a more specific error code (example:** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)** can be obtained by calling [sqlite3_reset()] on the** [sqlite_stmt | prepared statement]. In the "v2" interface,** the more specific error code is returned directly by sqlite3_step().**** [SQLITE_MISUSE] means that the this routine was called inappropriately.** Perhaps it was called on a [sqlite_stmt | prepared statement] that has** already been [sqlite3_finalize | finalized] or on one that had ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could** be the case that the same database connection is being used by two or** more threads at the same moment in time.**** <b>Goofy Interface Alert:</b>** In the legacy interface, ** the sqlite3_step() API always returns a generic error code,** [SQLITE_ERROR], following any error other than [SQLITE_BUSY]** and [SQLITE_MISUSE]. You must call [sqlite3_reset()] or** [sqlite3_finalize()] in order to find one of the specific** [SQLITE_ERROR | result codes] that better describes the error.** We admit that this is a goofy design. The problem has been fixed** with the "v2" interface. If you prepare all of your SQL statements** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()], then the ** more specific [SQLITE_ERROR | result codes] are returned directly** by sqlite3_step(). The use of the "v2" interface is recommended.*/int sqlite3_step(sqlite3_stmt*);/*** CAPI3REF:**** Return the number of values in the current row of the result set.**** After a call to [sqlite3_step()] that returns [SQLITE_ROW], this routine** will return the same value as the [sqlite3_column_count()] function.** After [sqlite3_step()] has returned an [SQLITE_DONE], [SQLITE_BUSY], or** a [SQLITE_ERROR | error code], or before [sqlite3_step()] has been ** called on the [sqlite_stmt | prepared statement] for the first time,** this routine returns zero.*/int sqlite3_data_count(sqlite3_stmt *pStmt);/*** CAPI3REF: Fundamental Datatypes**** Every value in SQLite has one of five fundamental datatypes:**** <ul>** <li> 64-bit signed integer** <li> 64-bit IEEE floating point number** <li> string** <li> BLOB** <li> NULL** </ul>**** These constants are codes for each of those types.**** Note that the SQLITE_TEXT constant was also used in SQLite version 2** for a completely different meaning. Software that links against both** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT not** SQLITE_TEXT.*/#define SQLITE_INTEGER 1#define SQLITE_FLOAT 2#define SQLITE_BLOB 4#define SQLITE_NULL 5#ifdef SQLITE_TEXT# undef SQLITE_TEXT#else# define SQLITE_TEXT 3#endif#define SQLITE3_TEXT 3/*** CAPI3REF: Results Values From A Query**** These routines return information about the information** in a single column of the current result row of a query. In every** case the first argument is a pointer to the ** [sqlite3_stmt | SQL statement] that is being** evaluate (the [sqlite_stmt*] that was returned from ** [sqlite3_prepare_v2()] or one of its variants) and** the second argument is the index of the column for which information ** should be returned. The left-most column has an index of 0.**** If the SQL statement is not currently point to a valid row, or if the** the column index is out of range, the result is undefined.**** The sqlite3_column_type() routine returns ** [SQLITE_INTEGER | datatype code] for the initial data type** of the result column. The returned value is one of [SQLITE_INTEGER],** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value** returned by sqlite3_column_type() is only meaningful if no type** conversions have occurred as described below. After a type conversion,** the value returned by sqlite3_column_type() is undefined. Future** versions of SQLite may change the behavior of sqlite3_column_type()** following a type conversion.***** The sqlite3_column_nm**** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() ** routine returns the number of bytes in that BLOB or string.** If the result is a UTF-16 string, then sqlite3_column_bytes() converts** the string to UTF-8 and then returns the number of bytes.** If the result is a numeric value then sqlite3_column_bytes() uses** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns** the number of bytes in that string.** The value returned does not include the zero terminator at the end** of the string. For clarity: the value returned is the number of**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -