Name

sqlite3_result_error_xxx() — Return an error condition from an SQL function

Definition

void sqlite3_result_error(        sqlite3_context* ctx,
                                           const char* msg, int bytes );
void sqlite3_result_error16(      sqlite3_context* ctx,
                                           const void* msg, int bytes );
void sqlite3_result_error_code(   sqlite3_context* ctx, int errcode );
void sqlite3_result_error_nomem(  sqlite3_context* ctx );
void sqlite3_result_error_toobig( sqlite3_context* ctx );
ctx

An SQL function context, provided by the SQLite library.

msg

The error message to return, in UTF-8 or UTF-16 encoding.

bytes

The size of the error message, in bytes (not characters).

errcode

An SQLite result code.

Description

These functions return an error from an SQL function implementation. This will cause an SQL exception to be thrown and sqlite3_step() to return the given error. A function may call one of these functions (and calls to sqlite3_result_xxx()) as many times as needed to update or reset the result error.

The functions sqlite3_result_error() and sqlite3_result_error16() will set the result error to SQLITE_ERROR and pass back the provided error message. A copy is made of the error message, so there is no need to keep the message buffer valid after the function returns.

The function sqlite3_result_error_code() sets an SQLite result code other than SQLITE_ERROR. Because sqlite3_result_error[16]() sets the result code to SQLITE_ERROR, passing back both a custom message and error code requires setting the message, followed by the result code. ...

Get Using SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.