📄 sqlite3.h
字号:
*/const void *sqlite3_errmsg16(sqlite3*);/*** An instance of the following opaque structure is used to represent** a compiled SQL statment.*/typedef struct sqlite3_stmt sqlite3_stmt;/*** To execute an SQL query, it must first be compiled into a byte-code** program using one of the following routines. The only difference between** them is that the second argument, specifying the SQL statement to** compile, is assumed to be encoded in UTF-8 for the sqlite3_prepare()** function and UTF-16 for sqlite3_prepare16().**** The first parameter "db" is an SQLite database handle. The second** parameter "zSql" is the statement to be compiled, encoded as either** UTF-8 or UTF-16 (see above). If the next parameter, "nBytes", is less** than zero, then zSql is read up to the first nul terminator. If** "nBytes" is not less than zero, then it is the length of the string zSql** in bytes (not characters).**** *pzTail is made to point to the first byte past the end of the first** SQL statement in zSql. This routine only compiles the first statement** in zSql, so *pzTail is left pointing to what remains uncompiled.**** *ppStmt is left pointing to a compiled SQL statement that can be** executed using sqlite3_step(). Or if there is an error, *ppStmt may be** set to NULL. If the input text contained no SQL (if the input is and** empty string or a comment) then *ppStmt is set to NULL.**** On success, SQLITE_OK is returned. Otherwise an error code is returned.*/int sqlite3_prepare( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nBytes, /* Length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */);int sqlite3_prepare16( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nBytes, /* Length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */);/*** Pointers to the following two opaque structures are used to communicate** with the implementations of user-defined functions.*/typedef struct sqlite3_context sqlite3_context;typedef struct Mem sqlite3_value;/*** In the SQL strings input to sqlite3_prepare() and sqlite3_prepare16(),** one or more literals can be replace by parameters "?" or ":AAA" or** "$VVV" where AAA is an identifer and VVV is a variable name according** to the syntax rules of the TCL programming language.** The value of these parameters (also called "host parameter names") can** be set using the routines listed below.**** In every case, the first parameter is a pointer to the sqlite3_stmt** structure returned from sqlite3_prepare(). The second parameter is the** index of the parameter. The first parameter as an index of 1. For** named parameters (":AAA" or "$VVV") you can use ** sqlite3_bind_parameter_index() to get the correct index value given** the parameters name. If the same named parameter occurs more than** once, it is assigned the same index each time.**** The fifth parameter to sqlite3_bind_blob(), sqlite3_bind_text(), and** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or** text after SQLite has finished with it. If the fifth argument is the** special value SQLITE_STATIC, then the library assumes that the information** is in static, unmanaged space and does not need to be freed. If the** fifth argument has the value SQLITE_TRANSIENT, then SQLite makes its** own private copy of the data.**** The sqlite3_bind_* routine must be called before sqlite3_step() after** an sqlite3_prepare() or sqlite3_reset(). Unbound parameterss are** interpreted as NULL.*/int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));int sqlite3_bind_double(sqlite3_stmt*, int, double);int sqlite3_bind_int(sqlite3_stmt*, int, int);int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite_int64);int sqlite3_bind_null(sqlite3_stmt*, int);int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);/*** Return the number of parameters in a compiled SQL statement. This** routine was added to support DBD::SQLite.*/int sqlite3_bind_parameter_count(sqlite3_stmt*);/*** Return the name of the i-th parameter. Ordinary parameters "?" are** nameless and a NULL is returned. For parameters of the form :AAA or** $VVV the complete text of the parameter name is returned, including** the initial ":" or "$". NULL is returned if the index is out of range.*/const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);/*** Return the index of a parameter with the given name. The name** must match exactly. If no parameter with the given name is found,** return 0.*/int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);/*** Set all the parameters in the compiled SQL statement to NULL.*/int sqlite3_clear_bindings(sqlite3_stmt*);/*** Return the number of columns in the result set returned by the 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);/*** The first parameter is a compiled SQL statement. This function returns** the column heading for the Nth column of that statement, where N is the** second function parameter. The string returned is UTF-8 for** sqlite3_column_name() and UTF-16 for sqlite3_column_name16().*/const char *sqlite3_column_name(sqlite3_stmt*,int);const void *sqlite3_column_name16(sqlite3_stmt*,int);/*** The first parameter to the following calls is a 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 not a column value,** then all of the functions return NULL. Otherwise, the return the ** name of the attached database, table and column that the expression** extracts a value from.**** As with all other SQLite APIs, those postfixed with "16" return UTF-16** encoded strings, the other functions return UTF-8. The memory containing** the returned strings is valid until the statement handle is finalized().**** 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);/*** The first parameter is a compiled 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 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).*/const char *sqlite3_column_decltype(sqlite3_stmt *, int i);/*** The first parameter is a compiled 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 always** UTF-16 encoded. For example, in the database schema:**** CREATE TABLE t1(c1 INTEGER);**** And the following statement compiled:**** SELECT c1 + 1, c1 FROM t1;**** 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).*/const void *sqlite3_column_decltype16(sqlite3_stmt*,int);/* ** After an SQL query has been compiled with a call to either** sqlite3_prepare() or sqlite3_prepare16(), then this function 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 sqlite3_step() again to retry the open.**** SQLITE_DONE means that the statement has finished executing** successfully. sqlite3_step() should not be called again on this virtual** machine.**** 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_*() functions described below. 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().**** 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 the the same database connection** is being used simulataneously by two or more threads.*/int sqlite3_step(sqlite3_stmt*);/*** 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 ** compiled SQL statement, this routine returns zero.*/int sqlite3_data_count(sqlite3_stmt *pStmt);/*** Values are stored in the database in one of the following fundamental** types.*/#define SQLITE_INTEGER 1#define SQLITE_FLOAT 2/* #define SQLITE_TEXT 3 // See below */#define SQLITE_BLOB 4#define SQLITE_NULL 5/*** SQLite version 2 defines SQLITE_TEXT differently. To allow both** version 2 and version 3 to be included, undefine them both if a** conflict is seen. Define SQLITE3_TEXT to be the version 3 value.*/#ifdef SQLITE_TEXT# undef SQLITE_TEXT#else# define SQLITE_TEXT 3#endif#define SQLITE3_TEXT 3/*** The next group of routines returns information about the information** in a single column of the current result row of a query. In every** case the first parameter is a pointer to the SQL statement that is being** executed (the sqlite_stmt* that was returned from sqlite3_prepare()) and** the second argument is the index of the column for which information ** should be returned. iCol is zero-indexed. The left-most column as an** index of 0.**** If the SQL statement is not currently point to a valid row, or if the** the colulmn index is out of range, the result is undefined.**** 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:**** Internal Type Requested Type Conversion** ------------- -------------- --------------------------** NULL INTEGER Result is 0** NULL FLOAT Result is 0.0** NULL TEXT Result is an empty string** NULL BLOB Result is a zero-length BLOB** INTEGER FLOAT Convert from integer to float** INTEGER TEXT ASCII rendering of the integer** INTEGER BLOB Same as for INTEGER->TEXT** FLOAT INTEGER Convert from float to integer** FLOAT TEXT ASCII rendering of the float** FLOAT BLOB Same as FLOAT->TEXT** TEXT INTEGER Use atoi()** TEXT FLOAT Use atof()** TEXT BLOB No change** BLOB INTEGER Convert to TEXT then use atoi()** BLOB FLOAT Convert to TEXT then use atof()** BLOB TEXT Add a \000 terminator if needed**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -