LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

ecpg

PostgreSQL embedded SQL preprocessor

TLDR

Preprocess embedded SQL file
$ ecpg [file.pgc]
copy
Specify output file
$ ecpg -o [output.c] [input.pgc]
copy
Include search path
$ ecpg -I [/include/path] [file.pgc]
copy
Enable compatibility mode
$ ecpg -C [INFORMIX] [file.pgc]
copy
Process a header file containing embedded SQL declarations
$ ecpg -h [header.pgh]
copy
Use question marks as parameter placeholders (Informix style)
$ ecpg -r [questionmarks] [file.pgc]
copy

SYNOPSIS

ecpg [options] file...

DESCRIPTION

ecpg is the PostgreSQL embedded SQL preprocessor. It converts C programs with embedded SQL statements into regular C code that calls the ECPG runtime library, which in turn talks to the server through libpq.The tool reads .pgc files containing EXEC SQL statements embedded in C code and generates standard C files. By default the output for `prog.pgc` is written to `prog.c`. The generated code must be compiled and linked against libecpg (for example with `gcc prog.c -lecpg`), and the include path from `pg_config --includedir` is usually needed.

PARAMETERS

-o file

Write output to file.
-I directory
Include search path.
-c
Automatically generate C code from SQL code, currently for EXEC SQL TYPE declarations.
-C mode
Compatibility mode: INFORMIX, INFORMIX_SE or ORACLE.
-D symbol[=value]
Define a C preprocessor symbol.
-h
Process a header file. Implies -c and writes a .h file rather than a .c file.
-i
Parse system include files as well.
-r option
Set a run-time behavior: no_indicator, prepare, questionmarks.
-t
Turn on autocommit of transactions.
-v
Print version, include path and other build information.
--version
Print version and exit.

INSTALL

sudo apt install libecpg-dev
copy
sudo apk add libecpg-dev
copy

CAVEATS

The generated C file links against libecpg, not libpq directly, so the PostgreSQL client development package must be installed. Compatibility modes change SQL parsing and null handling to match Informix or Oracle, and code written for one mode is generally not portable to another.

SEE ALSO

psql(1), pg_config(1), postgres(1)

RESOURCES

Copied to clipboard
Kai