ecpg − embedded SQL C preprocessor


ecpg [option...] file...


ecpg is the embedded SQL preprocessor for C programs. It converts C programs with embedded SQL statements to normal C code by replacing the SQL invocations with special function calls. The output files can then be processed with any C compiler tool chain.

ecpg will convert each input file given on the command line to the corresponding C output file. Input files preferably have the extension .pgc, in which case the extension will be replaced by .c to determine the output file name. If the extension of the input file is not .pgc, then the output file name is computed by appending .c to the full file name. The output file name can also be overridden using the −o option.

This reference page does not describe the embedded SQL language. See Chapter 33, ECPG - Embedded SQL in C, in the documentation for more information on that topic.


ecpg accepts the following command−line arguments:


Automatically generate certain C code from SQL code. Currently, this works for EXEC SQL TYPE.

−C mode

Set a compatibility mode. mode can be INFORMIX or INFORMIX_SE.

−D symbol

Define a C preprocessor symbol.


Parse system include files as well.

−I directory

Specify an additional include path, used to find files included via EXEC SQL INCLUDE. Defaults are . (current directory), /usr/local/include, the PostgreSQL include directory which is defined at compile time (default: /usr/local/pgsql/include), and /usr/include, in that order.

−o filename

Specifies that ecpg should write all its output to the given filename.

−r option

Selects run−time behavior. Option can be one of the following:


Do not use indicators but instead use special values to represent null values. Historically there have been databases using this approach.


Prepare all statements before using them. Libecpg will keep a cache of prepared statements and reuse a statement if it gets executed again. If the cache runs full, libecpg will free the least used statement.


Allow question mark as placeholder for compatibility reasons. This used to be the default long ago.


Turn on autocommit of transactions. In this mode, each SQL command is automatically committed unless it is inside an explicit transaction block. In the default mode, commands are committed only when EXEC SQL COMMIT is issued.


Print additional information including the version and the "include" path.


Print the ecpg version and exit.


Show help about ecpg command line arguments, and exit.


When compiling the preprocessed C code files, the compiler needs to be able to find the ECPG header files in the PostgreSQL include directory. Therefore, you might have to use the −I option when invoking the compiler (e.g., −I/usr/local/pgsql/include).

Programs using C code with embedded SQL have to be linked against the libecpg library, for example using the linker options −L/usr/local/pgsql/lib −lecpg.

The value of either of these directories that is appropriate for the installation can be found out using pg_config(1).


If you have an embedded SQL C source file named prog1.pgc, you can create an executable program using the following sequence of commands:

ecpg prog1.pgc
cc −I/usr/local/pgsql/include −c prog1.c
cc −o prog1 prog1.o −L/usr/local/pgsql/lib −lecpg

More Linux Commands

Tk_IsEmbedded(3) - retrieve information from Tk's local data
Tk_WindowId and the other names listed above are all macros that return fields from Tks local data structure for tkwin. None of these macros requires any intera

ltrace(1) - A library call tracer - Linux manual page.......
ltrace is a program that simply runs the specified command until it exits. It intercepts and records the dynamic library calls which are called by the executed

systemd-run(1) Run programs in transient scope or service un
systemd-run may be used to create and start a transient .service or a .scope unit and run the specified COMMAND in it. If a command is run as transient service

Tcl_StringCaseMatch(3) - test whether a string matches a pat
This utility procedure determines whether a string matches a given pattern. If it does, then Tcl_StringMatch returns 1. Otherwise Tcl_StringMatch returns 0. The

perl5161delta(1) what is new for perl v5.16.1 (Man Page)....
This document describes differences between the 5.16.0 release and the 5.16.1 release. If you are upgrading from an earlier release such as 5.14.0, first read p

setitimer(2) - get or set value of an interval timer........
The system provides each process with three interval timers, each decrementing in a distinct time domain. When any timer expires, a signal is sent to the proces

XDestroyImage(3) - image utilities - Linux manual page......
The XInitImage function initializes the internal image manipulation routines of an image structure, based on the values of the various structure members. All fi

XFontProp(3) - load or unload fonts and font metric structur
The XLoadFont function loads the specified font and returns its associated font ID. If the font name is not in the Host Portable Character Encoding, the result

ncursesw5-config(1) - helper script for ncurses libraries...
ncursesw5-config.1 - This is a shell script which simplifies configuring applications against a particular set of ncurses libraries. OPTIONS --prefix echos the

ggz(6) - GGZ Gaming Zone core client selector (Man Page)....
The GGZ Gaming Zone allows people to play many games online using so-called GGZ core clients which are chat clients with integrated game launchers. The ggz tool

Tk_IdToWindow(3) - Find Tk's window information for an X win
Given an X window identifier and the X display it corresponds to, this procedure returns the corresponding Tk_Window handle. If there is no Tk_Window correspond

smbstatus(1) - report on current Samba connections (ManPage)
This tool is part of the samba(7) suite. smbstatus is a very simple program to list the current Samba connections. OPTIONS -P|--profile If samba has been compil

We can't live, work or learn in freedom unless the software we use is free.