The callback function format is as follows: Int Sqlite_callback ( Void * PV, /* Passed by the fourth parameter of sqlite3_exec () */ Int Argc, /* Number of columns in the table */ Char ** Argv, /* The pointer array pointing to the query result, which can be obtained by sqlite3_column_text (). */ Char ** Col /* Pointer array pointing to the header name, which can be obtained by sqlite3_column_name () */ );
Parameter format: The callback function passed to sqlite3_exec to display the query result. Each query result is called once. The callback function parameter: PV: the number of columns in the table header. Col: header name array pointer argv: header data array pointer returned value: 1: interrupted search 0: continue listing queried data
Example Table: + ------------------------------- + | ID | PIC | data (hexadecimal data) | ------------------------------------- | 1 | a.jpg | 00 00 00... | ------------------------------- | 2 | B .jpg | xx | + ------------------------------------- + for the first row of data: argc = 3 [0]... [2] argv [0] = "1", argv [1] = "a.jpg", argv [2] = "00 00 00... "(actual hexadecimal data, not the string format shown here) COL [0] =" ID ", Col [1] =" pic ", col [2] = "data"
note: the callback function of sqlite3_exec () must follow this format. Of course, the parameter name is arbitrary. if the data type of a column is not Char *, you can convert the result. For example, you can use atoi () to convert the result to an integer ), if it is binary data, you can directly force type conversion, such as: ( void * ) argv [I]. the callback function has two types of return values. 1 . return zero: sqlite3_exec (). The query continues. 2 . return non-zero: sqlite3_exec () will immediately interrupt the query, and sqlite3_exec () will return sqlite_abort. example: int I; for (I = 0 ; I
) {printf (
"
% s \ t % s \ n
"
, Col [I], argv [I]) ;}
girls don't cry (QQ: 191035066) @ 2012-05-29 13:13:48 @ http://www.cnblogs.com/nbsofer