📄 capi3ref.tcl
字号:
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 at 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, 0 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).}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 can be used, a single callback function may be registered with the database handle to be called whenever an undefined collation sequence is required. If the function is registered using the sqlite3_collation_needed() API, then it is passed the names of undefined collation sequences as strings encoded in UTF-8. If sqlite3_collation_needed16() is used, the names are passed as UTF-16 in machine native byte order. A call to either function replaces any existing callback. When the user-function is invoked, the first argument passed is a copy of the second argument to sqlite3_collation_needed() or sqlite3_collation_needed16(). The second argument is the database handle. The third argument is one of SQLITE_UTF8, SQLITE_UTF16BE or SQLITE_UTF16LE, indicating the most desirable form of the collation sequence function required. The fourth argument is the name of the required collation sequence. The collation sequence is returned to SQLite by a collation-needed callback using the sqlite3_create_collation() or sqlite3_create_collation16() APIs, described above.}api {} {int sqlite3_create_function( sqlite3 *, const char *zFunctionName, int nArg, int eTextRep, void *pUserData, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*));int sqlite3_create_function16( sqlite3*, const void *zFunctionName, int nArg, int eTextRep, void *pUserData, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*));#define SQLITE_UTF8 1#define SQLITE_UTF16 2#define SQLITE_UTF16BE 3#define SQLITE_UTF16LE 4#define SQLITE_ANY 5} { These two functions are used to add SQL functions or aggregates implemented in C. The only difference between these two routines is that the second argument, the name of the (scalar) function or aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16 for sqlite3_create_function16(). The first argument is the database handle that the new function or aggregate is to be added to. If a single program uses more than one database handle internally, then user functions or aggregates must be added individually to each database handle with which they will be used. The third argument is the number of arguments that the function or aggregate takes. If this argument is -1 then the function or aggregate may take any number of arguments. The fourth argument, eTextRep, specifies what type of text arguments this function prefers to receive. Any function should be able to work work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be more efficient with one representation than another. Users are allowed to specify separate implementations for the same function which are called depending on the text representation of the arguments. The the implementation which provides the best match is used. If there is only a single implementation which does not care what text representation is used, then the fourth argument should be SQLITE_ANY. The fifth argument is an arbitrary pointer. The function implementations can gain access to this pointer using the sqlite_user_data() API. The sixth, seventh and eighth argumens, xFunc, xStep and xFinal, are pointers to user implemented C functions that implement the user function or aggregate. A scalar function requires an implementation of the xFunc callback only, NULL pointers should be passed as the xStep and xFinal arguments. An aggregate function requires an implementation of xStep and xFinal, and NULL should be passed for xFunc. To delete an existing user function or aggregate, pass NULL for all three function callbacks. Specifying an inconstant set of callback values, such as an xFunc and an xFinal, or an xStep but no xFinal, results in an SQLITE_ERROR return.}api {} {int sqlite3_data_count(sqlite3_stmt *pStmt);} { 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 error code, or before sqlite3_step() has been called on a prepared SQL statement, this routine returns zero.}api {} {int sqlite3_errcode(sqlite3 *db);} { Return the error code for the most recent failed sqlite3_* API call associated with sqlite3 handle 'db'. If a prior API call failed but the most recent API call succeeded, the return value from this routine is undefined. Calls to many sqlite3_* functions set the error code and string returned by sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16() (overwriting the previous values). Note that calls to sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16() themselves do not affect the results of future invocations. Calls to API routines that do not return an error code (examples: sqlite3_data_count() or sqlite3_mprintf()) do not change the error code returned by this routine. Assuming no other intervening sqlite3_* API calls are made, the error code returned by this function is associated with the same error as the strings returned by sqlite3_errmsg() and sqlite3_errmsg16().} {}api {} {const char *sqlite3_errmsg(sqlite3*);const void *sqlite3_errmsg16(sqlite3*);} { Return a pointer to a UTF-8 encoded string (sqlite3_errmsg) or a UTF-16 encoded string (sqlite3_errmsg16) describing in English the error condition for the most recent sqlite3_* API call. The returned string is always terminated by an 0x00 byte. The string "not an error" is returned when the most recent API call was successful.}api {} {int sqlite3_exec( sqlite3*, /* An open database */ const char *sql, /* SQL to be executed */ sqlite_callback, /* Callback function */ void *, /* 1st argument to callback function */ char **errmsg /* Error msg written here */);} { A function to executes one or more statements of SQL.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -