Client 3—Processing Queries
Query processing is simple in libpgeasy. To execute a SQL command, you call the doquery() function. The function prototype for doquery() is
PGresult * doquery( char * query );
Notice that doquery() does not expect a PGconn *—libpgeasy can deal with only a single database connection and it implicitly uses the one returned by connectdb(). doquery() returns a PGresult *. This is the same data structure you saw in the previous chapter—it represents the result set of the query.
After you have executed a command, you will need to process the result set. libpgeasy provides a number of functions for dealing with a result set—of course, you can use any of the libpq functions as well.
If you are reasonably sure that your query ...
Get PostgreSQL, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.