📄 capi3ref.tcl
字号:
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. If the result is a BLOB then the sqlite3_column_bytes() routine returns the number of bytes in that BLOB. No type conversions occur. If the result is a string (or a number since a number can be converted into a string) then sqlite3_column_bytes() converts the value into a UTF-8 string and returns the number of bytes in the resulting string. The value returned does not include the \\000 terminator at the end of the string. The sqlite3_column_bytes16() routine converts the value into a UTF-16 encoding and returns the number of bytes (not characters) in the resulting string. The \\u0000 terminator is not included in this count. These routines attempt to convert the value where appropriate. For example, if the internal representation is FLOAT and a text result is requested, sprintf() is used internally to do the conversion automatically. The following table details the conversions that are applied:<blockquote><table border="1"><tr><th>Internal Type</th><th>Requested Type</th><th>Conversion</th></tr><tr><td> NULL </td><td> INTEGER</td><td>Result is 0</td></tr><tr><td> NULL </td><td> FLOAT </td><td> Result is 0.0</td></tr><tr><td> NULL </td><td> TEXT </td><td> Result is NULL pointer</td></tr><tr><td> NULL </td><td> BLOB </td><td> Result is NULL pointer</td></tr><tr><td> INTEGER </td><td> FLOAT </td><td> Convert from integer to float</td></tr><tr><td> INTEGER </td><td> TEXT </td><td> ASCII rendering of the integer</td></tr><tr><td> INTEGER </td><td> BLOB </td><td> Same as for INTEGER->TEXT</td></tr><tr><td> FLOAT </td><td> INTEGER</td><td>Convert from float to integer</td></tr><tr><td> FLOAT </td><td> TEXT </td><td> ASCII rendering of the float</td></tr><tr><td> FLOAT </td><td> BLOB </td><td> Same as FLOAT->TEXT</td></tr><tr><td> TEXT </td><td> INTEGER</td><td>Use atoi()</td></tr><tr><td> TEXT </td><td> FLOAT </td><td> Use atof()</td></tr><tr><td> TEXT </td><td> BLOB </td><td> No change</td></tr><tr><td> BLOB </td><td> INTEGER</td><td>Convert to TEXT then use atoi()</td></tr><tr><td> BLOB </td><td> FLOAT </td><td> Convert to TEXT then use atof()</td></tr><tr><td> BLOB </td><td> TEXT </td><td> Add a \\000 terminator if needed</td></tr></table></blockquote>}api {} {int sqlite3_column_count(sqlite3_stmt *pStmt);} { Return the number of columns in the result set returned by the prepared SQL statement. This routine returns 0 if pStmt is an SQL statement that does not return data (for example an UPDATE). See also sqlite3_data_count().}api {} {const char *sqlite3_column_decltype(sqlite3_stmt *, int i);const void *sqlite3_column_decltype16(sqlite3_stmt*,int);} { The first argument is a prepared SQL statement. If this statement is a SELECT statement, the Nth column of the returned result set of the SELECT is a table column then the declared type of the table column is returned. If the Nth column of the result set is not a table column, then a NULL pointer is returned. The returned string is UTF-8 encoded for sqlite3_column_decltype() and UTF-16 encoded for sqlite3_column_decltype16(). For example, in the database schema: <blockquote><pre> CREATE TABLE t1(c1 INTEGER); </pre></blockquote> And the following statement compiled: <blockquote><pre> SELECT c1 + 1, c1 FROM t1; </pre></blockquote> Then this routine would return the string "INTEGER" for the second result column (i==1), and a NULL pointer for the first result column (i==0). If the following statements were compiled then this routine would return "INTEGER" for the first (only) result column. <blockquote><pre> 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); </pre></blockquote>}api {} { int sqlite3_table_column_metadata( sqlite3 *db, /* Connection handle */ const char *zDbName, /* Database name or NULL */ const char *zTableName, /* Table name */ const char *zColumnName, /* Column name */ char const **pzDataType, /* OUTPUT: Declared data type */ char const **pzCollSeq, /* OUTPUT: Collation sequence name */ int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ int *pPrimaryKey, /* OUTPUT: True if column part of PK */ int *pAutoinc /* OUTPUT: True if colums is auto-increment */ );} { This routine is used to obtain meta information about a specific column of a specific database table accessible using the connection handle passed as the first function argument. The column is identified by the second, third and fourth parameters to this function. The second parameter is either the name of the database (i.e. "main", "temp" or an attached database) containing the specified table or NULL. If it is NULL, then all attached databases are searched for the table using the same algorithm as the database engine uses to resolve unqualified table references. The third and fourth parameters to this function are the table and column name of the desired column, respectively. Neither of these parameters may be NULL. Meta information is returned by writing to the memory locations passed as the 5th and subsequent parameters to this function. Any of these arguments may be NULL, in which case the corresponding element of meta information is ommitted.<pre> Parameter Output Type Description ----------------------------------- 5th const char* Declared data type 6th const char* Name of the columns default collation sequence 7th int True if the column has a NOT NULL constraint 8th int True if the column is part of the PRIMARY KEY 9th int True if the column is AUTOINCREMENT</pre> The memory pointed to by the character pointers returned for the declaration type and collation sequence is valid only until the next call to any sqlite API function. This function may load one or more schemas from database files. If an error occurs during this process, or if the requested table or column cannot be found, an SQLITE error code is returned and an error message left in the database handle (to be retrieved using sqlite3_errmsg()). Specifying an SQL view instead of a table as the third argument is also considered an error. If the specified column is "rowid", "oid" or "_rowid_" and an INTEGER PRIMARY KEY column has been explicitly declared, then the output parameters are set for the explicitly declared column. If there is no explicitly declared IPK column, then the data-type is "INTEGER", the collation sequence "BINARY" and the primary-key flag is set. Both the not-null and auto-increment flags are clear. This API is only available if the library was compiled with the SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.}api {} {const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N);const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N);} {If the Nth column returned by statement pStmt is a column reference,these functions may be used to access the name of the database (either "main", "temp" or the name of an attached database) that containsthe column. If the Nth column is not a column reference, NULL isreturned.See the description of function sqlite3_column_decltype() for adescription of exactly which expressions are considered column references.Function sqlite3_column_database_name() returns a pointer to a UTF-8encoded string. sqlite3_column_database_name16() returns a pointerto a UTF-16 encoded string. }api {} {const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N);const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N);} {If the Nth column returned by statement pStmt is a column reference,these functions may be used to access the schema name of the referenced column in the database schema. If the Nth column is not a column reference, NULL is returned.See the description of function sqlite3_column_decltype() for adescription of exactly which expressions are considered column references.Function sqlite3_column_origin_name() returns a pointer to a UTF-8encoded string. sqlite3_column_origin_name16() returns a pointerto a UTF-16 encoded string. }api {} {const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N);const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N);} {If the Nth column returned by statement pStmt is a column reference, these functions may be used to access the name of the table that contains the column. If the Nth column is not a column reference, NULL is returned.See the description of function sqlite3_column_decltype() for adescription of exactly which expressions are considered column references.Function sqlite3_column_table_name() returns a pointer to a UTF-8encoded string. sqlite3_column_table_name16() returns a pointerto a UTF-16 encoded string. }api {} {const char *sqlite3_column_name(sqlite3_stmt*,int);const void *sqlite3_column_name16(sqlite3_stmt*,int);} { The first argument is a prepared SQL statement. This function returns the column heading for the Nth column of that statement, where N is the second function argument. The string returned is UTF-8 for sqlite3_column_name() and UTF-16 for sqlite3_column_name16().}api {} {void *sqlite3_commit_hook(sqlite3*, int(*xCallback)(void*), void *pArg);} { <i>Experimental</i> Register a callback function to be invoked whenever a new transaction is committed. The pArg argument is passed through to the callback. callback. If the callback function returns non-zero, then the commit is converted into a rollback. If another function was previously registered, its pArg value is returned. Otherwise NULL is returned. Registering a NULL function disables the callback. Only a single commit hook callback can be registered at a time.}api {} {int sqlite3_complete(const char *sql);int sqlite3_complete16(const void *sql);} { These functions return true if the given input string comprises one or more complete SQL statements. The argument must be a nul-terminated UTF-8 string for sqlite3_complete() and a nul-terminated UTF-16 string for sqlite3_complete16().} {}api {} {int sqlite3_create_collation( sqlite3*, const char *zName, int pref16, void*, int(*xCompare)(void*,int,const void*,int,const void*));int sqlite3_create_collation16( sqlite3*, const char *zName, int pref16, void*, int(*xCompare)(void*,int,const void*,int,const void*));#define SQLITE_UTF8 1#define SQLITE_UTF16BE 2#define SQLITE_UTF16LE 3#define SQLITE_UTF16 4} { These two functions are used to add new collation sequences to the sqlite3 handle specified as the first argument. The name of the new collation sequence is specified as a UTF-8 string for sqlite3_create_collation() and a UTF-16 string for sqlite3_create_collation16(). In both cases the name is passed as the second function argument. The third argument must be one of the constants SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE, indicating that the user-supplied routine expects to be passed pointers to strings encoded using UTF-8, UTF-16 little-endian or UTF-16 big-endian respectively. The SQLITE_UTF16 constant indicates that text strings are expected in UTF-16 in the native byte order of the host machine. A pointer to the user supplied routine must be passed as the fifth argument. If it is NULL, this is the same as deleting the collation sequence (so that SQLite cannot call it anymore). Each time the user supplied function is invoked, it is passed a copy of the void* passed as the fourth argument to sqlite3_create_collation() or sqlite3_create_collation16() as its first argument. The remaining arguments to the user-supplied routine are two strings, each represented by a [length, data] pair and encoded in the encoding that was passed as the third argument when the collation sequence was registered. The user routine should return negative, zero or positive if the first string is less than, equal to, or greater than the second string. i.e. (STRING1 - STRING2).}api {} {int sqlite3_collation_needed( sqlite3*, void*, void(*)(void*,sqlite3*,int eTextRep,const char*));int sqlite3_collation_needed16( sqlite3*, void*, void(*)(void*,sqlite3*,int eTextRep,const void*));} { To avoid having to register all collation sequences before a database
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -