select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Supported versions: Current (18) / 17 / 16 / 15 / 14
Development versions: 19 / devel
Unsupported versions: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 7.2 / 7.1
Historical version. PostgreSQL 7.2 reached end of support in February 2007. See the current version for supported releases.

6.2. The Concept

You write your program in C/C++ with special SQL constructs. When declaring variables to be used in SQL statements, you need to put them in a special declare section. You use a special syntax for the SQL queries.

Before compiling you run the file through the embedded SQL C preprocessor and it converts the SQL statements you used to function calls with the variables used as arguments. Both query input and result output variables are passed.

After compiling, you must link with a special library that contains needed functions. These functions fetch information from the arguments, perform the SQL query using the libpq interface, and put the result in the arguments specified for output.

Report a documentation issue

Read the upstream documentation. For corrections, first check the current version.