加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Sqlite3 语句原文解析摘取

发布时间:2020-12-12 19:53:11 所属栏目:百科 来源:网络整理
导读:** ^The sqlite3_finalize() function is called to delete a [prepared statement]. ** The sqlite3_reset() function is called to reset a [prepared statement] ** object back to its initial state,ready to be re-executed. ** ^The number of column

** ^The sqlite3_finalize() function is called to delete a [prepared statement].


** The sqlite3_reset() function is called to reset a [prepared statement]

** object back to its initial state,ready to be re-executed.

** ^The number of columns in the result can be determined using

** [sqlite3_column_count()].

** ^The sqlite3_data_count(P) interface returns the number of columns in the

** current row of the result set of [prepared statement] P.


sqlite3_step

** After a [prepared statement] has been prepared using either

** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy

** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()],this function

** must be called one or more times to evaluate the statement.

**

** The details of the behavior of the 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.

sqlite3_column_name

** ^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 zero-terminated UTF-8 string

** and sqlite3_column_name16() returns a pointer to a zero-terminated

** UTF-16 string. ^The first parameter is the [prepared statement]

** that implements the [SELECT] statement. ^The second parameter is the

** column number. ^The leftmost column is number 0.

** ^The first argument to the sqlite3_bind_*() routines is always

** a pointer to the [sqlite3_stmt] object returned from

** [sqlite3_prepare_v2()] or its variants.


SQLITE_API int sqlite3_prepare(

sqlite3 *db,/* Database handle */

const char *zSql,/* SQL statement,UTF-8 encoded */

int nByte,/* Maximum length of zSql in bytes. */

sqlite3_stmt **ppStmt,/* OUT: Statement handle */

const char **pzTail /* OUT: Pointer to unused portion of zSql */

);

** The first argument,"db",is a [database connection] obtained from a

** prior successful call to [sqlite3_open()],[sqlite3_open_v2()] or

** [sqlite3_open16()]. The database connection must not have been closed.

** The second argument,"zSql",is the statement to be compiled,encoded

** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()

** interfaces use UTF-8,and sqlite3_prepare16() and sqlite3_prepare16_v2()

** use UTF-16.

/*

** CAPI3REF: SQL Statement Object

** KEYWORDS: {prepared statement} {prepared statements}

** An instance of this object represents a single SQL statement.

** This object is variously known as a "prepared statement" or a

** "compiled SQL statement" or simply as a "statement".

** The life of a statement object goes something like this:

** <ol>

** <li> Create the object using [sqlite3_prepare_v2()] or a related

** function.

** <li> Bind values to [host parameters] using the sqlite3_bind_*()

** interfaces.

** <li> Run the SQL by calling [sqlite3_step()] one or more times.

** <li> Reset the statement using [sqlite3_reset()] then go back

** to step 2. Do this zero or more times.

** <li> Destroy the object using [sqlite3_finalize()].

** </ol>

** Refer to documentation on individual methods above for additional

** information.

*/

typedef struct sqlite3_stmt sqlite3_stmt;


SQLITE_API int sqlite3_open(

const char *filename,/* Database filename (UTF-8) */

sqlite3 **ppDb /* OUT: SQLite db handle */

);

** CAPI3REF: Opening A New Database Connection

** ^These routines open an SQLite database file as specified by the

** filename argument. ^The filename argument is interpreted as UTF-8 for

** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte

** order for sqlite3_open16(). ^(A [database connection] handle is usually

** returned in *ppDb,even if an error occurs. The only exception is that

** if SQLite is unable to allocate memory to hold the [sqlite3] object,

** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]

** object.)^ ^(If the database is opened (and/or created) successfully,then

** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The

** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain

** an English language description of the error following a failure of any

** of the sqlite3_open() routines.

SQLITE_API void sqlite3_free(void*);

** ^Calling sqlite3_free() with a pointer previously returned

** by sqlite3_malloc() or sqlite3_realloc() releases that memory so

** that it might be reused. ^The sqlite3_free() routine is

** a no-op if is called with a NULL pointer. Passing a NULL pointer

** to sqlite3_free() is harmless. After being freed,memory

** should neither be read nor written. Even reading previously freed

** memory might result in a segmentation fault or other severe error.

** Memory corruption,a segmentation fault,or other severe error

** might result if sqlite3_free() is called with a non-NULL pointer that

** was not obtained from sqlite3_malloc() or sqlite3_realloc().

SQLITE_API int sqlite3_exec(

sqlite3*,/* An open database */

const char *sql,/* SQL to be evaluated */

int (*callback)(void*,int,char**,char**),/* Callback function */

void *,/* 1st argument to callback */

char **errmsg /* Error msg written here */

** <ul>

** <li> The application must insure that the 1st parameter to sqlite3_exec()

** is a valid and open [database connection].

** <li> The application must not close [database connection] specified by

** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.

** <li> The application must not modify the SQL statement text passed into

** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.

** </ul>

** The sqlite3_exec() interface is a convenience wrapper around

** [sqlite3_prepare_v2()],[sqlite3_step()],and [sqlite3_finalize()],87)"> ** that allows an application to run multiple statements of SQL

** without having to use a lot of C code.

SQLITE_API int sqlite3_close(sqlite3 *);

** CAPI3REF: Closing A Database Connection

** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.

** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is

** successfully destroyed and all associated resources are deallocated.

typedef struct sqlite3 sqlite3;

** CAPI3REF: Database Connection Handle

** KEYWORDS: {database connection} {database connections}


#define SQLITE_OK 0 /* Successful result */

/* beginning-of-error-codes */

#define SQLITE_ERROR 1 /* SQL error or missing database */

#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */

#define SQLITE_PERM 3 /* Access permission denied */

#define SQLITE_ABORT 4 /* Callback routine requested an abort */

#define SQLITE_BUSY 5 /* The database file is locked */

#define SQLITE_LOCKED 6 /* A table in the database is locked */

#define SQLITE_NOMEM 7 /* A malloc() failed */

#define SQLITE_READONLY 8 /* Attempt to write a readonly database */

#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/

#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */

#define SQLITE_CORRUPT 11 /* The database disk image is malformed */

#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */

#define SQLITE_FULL 13 /* Insertion failed because database is full */

#define SQLITE_CANTOPEN 14 /* Unable to open the database file */

#define SQLITE_PROTOCOL 15 /* Database lock protocol error */

#define SQLITE_EMPTY 16 /* Database is empty */

#define SQLITE_SCHEMA 17 /* The database schema changed */

#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */

#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */

#define SQLITE_MISMATCH 20 /* Data type mismatch */

#define SQLITE_MISUSE 21 /* Library used incorrectly */

#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */

#define SQLITE_AUTH 23 /* Authorization denied */

#define SQLITE_FORMAT 24 /* Auxiliary database format error */

#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */

#define SQLITE_NOTADB 26 /* File opened that is not a database file */

#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */

#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */

/* end-of-error-codes */



** CAPI3REF: Find the next prepared statement

** ^This interface returns a pointer to the next [prepared statement] after

** pStmt associated with the [database connection] pDb. ^If pStmt is NULL

** then this interface returns a pointer to the first prepared statement

** associated with the database connection pDb. ^If no prepared statement

** satisfies the conditions of this routine,it returns NULL.

** The [database connection] pointer D in a call to

** [sqlite3_next_stmt(D,S)] must refer to an open database

** connection and in particular must not be a NULL pointer.

*/

SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb,sqlite3_stmt *pStmt);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读