ecpg

Name

ecpg --  Embedded SQL C preprocessor

Synopsis

ecpg [ -v ] [ -t ] [ -I include-path ] [ -o outfile ]  file1 [ file2 ] [ ... ]
  

Inputs

file

The files to be processed.

-I path

Specify an additional include path. Defaults are ., /usr/local/include (the PostgreSQL include path, which is defined at compile time), and /usr/include.

-o

Specifies that ecpg should write all its output to outfile. If no such option is given the output is written to name.c, assuming the input file was named name.pgc. If the input file does have the expected .pgc suffix, then the output file will have .pgc appended to the input file name.

-t

Turn off auto-transaction mode.

-v

Print version information.

Outputs

ecpg will create a file or write to stdout.

return value

ecpg returns 0 to the shell on successful completion, -1 for errors.

Description

ecpg is an embedded SQL preprocessor for the C language and the PostgreSQL. It enables development of C programs with embedded SQL code.

Usage

Preprocessing for Compilation

An embedded SQL source file must be pre-processed before compilation:
ecpg [ -d ] [ -o file ] file.pgc
    
where the optional -d flag turns on debugging. The .pgc extension is an arbitrary means of denoting ecpg source.

You may want to redirect the preprocessor output to a log file.

Compiling and Linking

Assuming the PostgreSQL binaries are in /usr/local/pgsql, you will need to compile and link your pre-processed source file:
gcc -g -I /usr/local/pgsql/include [ -o file ] file.c -L /usr/local/pgsql/lib -lecpg -lpq