Database Reference
In-Depth Information
/* Data transfer start to/from server */
break;
default:
/* Unknown error */
break;
}
Using PQresStatus
This function converts the status code returned by the PQresultStatus function to
a string. The syntax for PQresStatus is as follows:
char *PQresStatus(ExecStatusType status);
The following code snippet executes a query and gets the status of the result
returned by PQexec using the PQresStatus function:
/* Execute a query using PQexec */
result = PQexec(conn, "SELECT id, name FROM foo LIMIT 3");
fprintf(stderr, "failed to execute query: %s\n",
PQresStatus(PQresultStatus(result)));
failed to execute query: PGRES_FATAL_ERROR
By default, libpq is thread safe and PQisthreadsafe can be used to check the status
of thread safety of libpq . The special compiler command-line options should be
used to compile the thread-based application.
Summary
This chapter explains different ways to establish a connection with the PostgreSQL
server and how to specify different options while connecting with database.
Further chapters throw light on how to query a database and manipulate
PostgreSQL data, that is, how to retrieve and insert data into the PostgreSQL server
using the libpq library.
 
Search WWH ::




Custom Search