Execute an SQL statement


#include <qdb/qdb.h>

int qdb_statement( qdb_hdt_t *hdl,
                   const char *format, 
                   ... );


A pointer to the database handle.
A string that controls the format of the output, as described below. The formatting string determines what additional arguments you need to provide. The string that results from the combination of format and the additional arguments is executed as a statement on the database referred to by hdl.




This function executes against the database all statements in the string generated by the combination of format and any additional arguments. A statement must be completed with a semicolon. The string may contain multiple statements as long as they are separated by semicolons. There's no arbitrary restriction on the length of the command string.

The format string and additional arguments work in the same way as the arguments for printf(), and all the same conversion specifiers apply. There are additional conversion type specifiers, %q and %Q, which in general should be used instead of %s for inserting text into a literal string. The %q type specifier properly escapes special characters for SQL. For more information, see qdb_mprintf().

If you are passing in multiple statements, the function returns the number of affected rows only for the last statement.

Note: By default, the SQL statement is executed on the database before qdb_statement() returns. However, if the connection is in asynchronous mode, this function can return before the statement is executed, and it may not report errors. In this case, you need to call qdb_getresult() to retrieve any errors generated by the statement. For more information, see Using asynchronous mode in qdb_connect().


An error occurred (errno is set).


QNX Neutrino

Interrupt handler No
Signal handler No
Thread Yes

See also:

qdb_mprintf(), qdb_vmprintf(), printf() in the Neutrino Library Reference