ECPG(1) | PostgreSQL 15.8 Documentation | ECPG(1) |
NAME¶
ecpg - embedded SQL C preprocessor
SYNOPSIS¶
ecpg [option...] file...
DESCRIPTION¶
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. If an input file name does not have any extension, .pgc is assumed. The file's extension will be replaced by .c to construct the output file name. But the output file name can be overridden using the -o option.
If an input file name is just -, ecpg reads the program from standard input (and writes to standard output, unless that is overridden with -o).
This reference page does not describe the embedded SQL language. See Chapter 36 for more information on that topic.
OPTIONS¶
ecpg accepts the following command-line arguments:
-c
-C mode
-D symbol[=value]
-h
-i
-I directory
-o filename
-r option
no_indicator
prepare
questionmarks
-t
-v
--version
-?
--help
NOTES¶
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).
EXAMPLES¶
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
2024 | PostgreSQL 15.8 |