Name
sqlite3_value_numeric_type() — Attempt to get an SQL function parameter as a number
Definition
int sqlite3_value_numeric_type( sqlite3_value* value );
-
value An SQL function parameter value.
- Returns
A datatype code.
Description
This function attempts to convert the given parameter
value into a numeric type. If the value can be converted into an
integer or floating-point number without loss of data, the
conversion is done and the type SQLITE_INTEGER or SQLITE_FLOAT will be returned.
If a conversion would result in lost data, the conversion is not
done and the original datatype is returned. In that case, the
type may be SQLITE_TEXT,
SQLITE_BLOB, or
SQLITE_NULL.
The difference between this function and simply calling a
function like sqlite3_value_int() is the conversion function.
This function will only perform the conversion if the original
value is fully consumed and makes sense in a numeric context.
For example, sqlite3_value_int()
will convert a NULL into the value
0, where this function will not. Similarly, sqlite3_value_int()
will convert the string 123xyz into the integer value 123 and ignore
the trailing xyz. This
function will not allow that conversion, however, because no
sense can be made of the trailing xyz in a numeric context.
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access