Retrieve declared column types for a prepared statement
#include <qdb/qdb.h> int qdb_stmt_decltypes(qdb_hdl_t *db, int stmtid, char **buf, ssize_t bufsize, ssize_t *required_size);
qdb
This function retrieves the declared column types for a prepared statement. The behavior of this function depends on how the arguments are set:
When this function returns, the beginning of buf is an array of pointers to strings which are also stored in the buffer, as illustrated in the following example:
char **pp; ssize_t required_size, bufsize = 0; int cols, i; if ((cols = qdb_stmt_decltypes(db, stmtid, NULL, 0, &required_size)) > 0) { pp = malloc(required_size); if (pp) { bufsize = required_size; cols = qdb_stmt_decltypes(db, stmtid, pp, bufsize, &required_size); for (i=0; i<cols; i++) printf("column %d: %s\n", i, pp[i]); free(pp); } }
You can optimize the the use of qdb_stmt_decltypes() by providing a buffer that you estimate should be large enough before calling qdb_stmt_decltypes() for the first time. On return, if bufsize is greater than or equal to required_size, all the data has been returned and you do not need to call this function again. This also allows re-use of a single, large enough buffer. |
QNX Neutrino
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
qdb_statement(), qdb_stmt_init()