Execute an SQL statement
#include <qdb/qdb.h> int qdb_statement( qdb_hdt_t *db, const char *format, ... );
qdb
This function combines the formatting string in format with the values of the additional arguments to construct an SQL command string and then executes that string on the database referred to by db.
Individual statements within the command string must be completed with and separated by semicolons. There's no length restriction for the command string.
The formatting string and additional arguments work in the same way as with printf() (all the same conversion specifiers apply). There are additional conversion specifiers, %q and %Q, which in general should be used instead of %s for inserting text into a literal string. The %q specifier properly escapes special characters for SQL. For more information, see qdb_mprintf().
To determine how many rows were affected by the SQL command string, you can call qdb_rowchanges() after executing the command string.
By default, the SQL code is executed on the database before qdb_statement() returns. However, if the connection is in asynchronous mode, this function may return before the SQL code completes execution and may not report errors. In this case, you need to call qdb_getresult() to retrieve any errors.
QNX Neutrino
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |