---
name: "pginterface"
section: "3"
platform: "linux"
package: "postgresql-contrib"
version: "6.5.3-27"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/pginterface"
---

# pginterface(3)

## DESCRIPTION

Pginterface allows you to cleanly interface to the libpq library, more like a 4gl SQL interface.

It consists of set of simplified C functions that encapsulate the functionality of libpq. The functions are:

```
PGresult   *doquery(char *query);
PGconn     *connectdb();
void        disconnectdb();
int         fetch(void *param,...);
int         fetchwithnulls(void *param,...);
void        reset_fetch();
void        on_error_continue();
void        on_error_stop();
PGresult   *get_result();
void        set_result(PGresult *newres);
void        unset_result(PGresult *oldres);
```

Many functions return a structure or value, so you can do more work with the result if required.

You basically connect to the database with **connectdb**, issue your query with **doquery**, fetch the results with **fetch**, and finish with **disconnectdb**.

For *select* queries, **fetch** allows you to pass pointers as parameters, and on return the variables are filled with data from the binary cursor you opened.  These binary cursors can not be used if you are running the **pginterface** client on a system with a different architecture than the database server.  If you pass a NULL pointer parameter, the column is skipped. **fetchwithnulls** allows you to retieve the *null* status of the field by passing an *int\** after each result pointer, which returns true or false if the field is null. You can always use libpq functions on the PGresult pointer returned by **doquery**. **reset\_fetch** starts the fetch back at the beginning.

**get\_result**, **set\_result**, and **unset\_result** allow you to handle multiple result sets at the same time.

There are a variety of demonstration programs in the **pginterface** examples in  */usr/doc/postgresql-contrib/pginterface*.
