sqlite3_value_*
const void *sqlite3_value_blob(sqlite3_value*);
int sqlite3_value_bytes(sqlite3_value*);
int sqlite3_value_bytes16(sqlite3_value*);
double sqlite3_value_double(sqlite3_value*);
int sqlite3_value_int(sqlite3_value*);
long long int sqlite3_value_int64(sqlite3_value*);
const unsigned char *sqlite3_value_text(sqlite3_value*);
const void *sqlite3_value_text16(sqlite3_value*);
const void *sqlite3_value_text16be(sqlite3_value*);
const void *sqlite3_value_text16le(sqlite3_value*);
int sqlite3_value_type(sqlite3_value*);
These API functions allow user-defined functions to access input data passed in by arguments.
The sqlite3_value_type() function returns one of:
- SQLITE_INTEGER
- SQLITE_FLOAT
- SQLITE_TEXT
- SQLITE_BLOB
- SQLITE_NULL
If the result is a BLOB, then the sqlite3_value_blob() function returns the number of bytes in the BLOB. No type conversions occur. If the result is a string (or a number, which can be converted into a string), then sqlite3_value_bytes() converts the value into UTF-8 encoding and returns the number of bytes in the resulting string, not including the \000 terminator. The sqlite3_value_bytes16() function converts the value into UTF-16 encoding and returns the number of bytes (not characters) in the resulting string, not including the \u0000 terminator.
These SQLite API functions attempt to convert the value where appropriate.
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 NULL pointer |
| NULL | BLOB | Result is NULL pointer |
| INTEGER | FLOAT | Convert from integer to float |
| INTEGER | TEXT | ASCII rendering of the integer |
| INTEGER | BLOB | Same as for INTEGER to TEXT |
| FLOAT | INTEGER | Convert from float to integer |
| FLOAT | TEXT | ASCII rendering of the float |
| FLOAT | BLOB | Same as FLOAT to 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 |
Page updated:
