Chapter 6. ecpg - Embedded SQL in C

Table of Contents
6.1. Why Embedded SQL?
6.2. The Concept
6.3. How To Use ecpg
6.3.1. Preprocessor
6.3.2. Library
6.3.3. Error handling
6.4. Limitations
6.5. Porting From Other RDBMS Packages
6.6. For the Developer
6.6.1. ToDo List
6.6.2. The Preprocessor
6.6.3. A Complete Example
6.6.4. The Library

This describes an embedded SQL in C package for Postgres. It was written by Linus Tolke () and Michael Meskes (). The package is installed with the Postgres distribution.

Note: Permission is granted to copy and use in the same way as you are allowed to copy and use the rest of PostgreSQL.

6.1. Why Embedded SQL?

Embedded SQL has some small advantages over other ways to handle SQL queries. It takes care of all the tedious moving of information to and from variables in your C program. Many RDBMS packages support this embedded language.

There is an ANSI-standard describing how the embedded language should work. ecpg was designed to meet this standard as much as possible. So it is possible to port programs with embedded SQL written for other RDBMS packages to Postgres and thus promoting the spirit of free software.