Database Reference
In-Depth Information
Using PQnparams
The PQnparams function returns the total number of parameters of a prepared
statement. The syntax for PQnparams is as follows:
int PQnparams(const PGresult *res);
Using PQparamtype
The PQparamtype function returns the data type of the indicated statement
parameter. The syntax for PQparamtype is as follows:
Oid PQparamtype(const PGresult *res, int param_number);
Here is the example to select the data from the PostgreSQL server. The following
program shows the usage of the PQexec , PQntuples , PQfnumber , and PQfinish
functions:
/*----------------------------------------------------------------
*
*retrieve.c
*Retrieving data using libpq
*
*IDENTIFICATION
*retrieve.c
*
*----------------------------------------------------------------
*/
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <limits.h>
#include "libpq-fe.h"
#include "libpq/libpq-fs.h"
char conninfo[] = "hostaddr = '127.0.0.1' port = '5432' dbname =
'postgres'";
int main(int argc, char **argv)
{
PGconn *conn; /* Connection Object */
PGresult *result;
int ntuples;
int i;
 
Search WWH ::




Custom Search