Database Reference
In-Depth Information
The PQprepare function is supported only in the protocol version
3.0 and higher. In the case of a version less than 3.0, this function
will fail.
The parameters for the PQprepare function are as follows:
stmtName : This is the name of the prepared statement
query : This is the query string
nParams : This is the number of parameters
paramTypes : This shows the data types of parameters
An unnamed portal will be created if stmtName is an empty string
and the previous unnamed portal will be overwritten.
Using PQexecPrepared
After preparing the query using PQprepare , we can execute the query using
PQexecPrepared . The PQexecPrepared function executes the previously prepared
statement. Its syntax is as follows:
PGresult *PQexecPrepared(PGconn *conn,
const char *stmtName,
int nParams,
const char * const *paramValues,
const int *paramLengths,
const int *paramFormats,
int resultFormat);
The parameters for the PQexecPrepared function are as follows:
paramValues : This shows the values of the array of parameters
paramLengths : This shows the length of the array of parameters
paramFormats : This shows the format of the array of parameters
resultFormat : This shows the result in the text or binary format
The PQexecPrepared function executes the query, which was prepared using the
PQprepare function. This function uses stmtName to identify which query needs to
be executed.
 
Search WWH ::




Custom Search