4 ecpg — embedded SQL C preprocessor
8 ecpg [option...] file...
12 ecpg is the embedded SQL preprocessor for C programs. It converts C
13 programs with embedded SQL statements to normal C code by replacing the
14 SQL invocations with special function calls. The output files can then
15 be processed with any C compiler tool chain.
17 ecpg will convert each input file given on the command line to the
18 corresponding C output file. If an input file name does not have any
19 extension, .pgc is assumed. The file's extension will be replaced by .c
20 to construct the output file name. But the output file name can be
21 overridden using the -o option.
23 If an input file name is just -, ecpg reads the program from standard
24 input (and writes to standard output, unless that is overridden with
27 This reference page does not describe the embedded SQL language. See
28 Chapter 34 for more information on that topic.
32 ecpg accepts the following command-line arguments:
35 Automatically generate certain C code from SQL code. Currently,
36 this works for EXEC SQL TYPE.
39 Set a compatibility mode. mode can be INFORMIX, INFORMIX_SE, or
43 Define a preprocessor symbol, equivalently to the EXEC SQL
44 DEFINE directive. If no value is specified, the symbol is
45 defined with the value 1.
48 Process header files. When this option is specified, the output
49 file extension becomes .h not .c, and the default input file
50 extension is .pgh not .pgc. Also, the -c option is forced on.
53 Parse system include files as well.
56 Specify an additional include path, used to find files included
57 via EXEC SQL INCLUDE. Defaults are . (current directory),
58 /usr/local/include, the PostgreSQL include directory which is
59 defined at compile time (default: /usr/local/pgsql/include), and
60 /usr/include, in that order.
63 Specifies that ecpg should write all its output to the given
64 filename. Write -o - to send all output to standard output.
67 Selects run-time behavior. Option can be one of the following:
70 Do not use indicators but instead use special values to
71 represent null values. Historically there have been
72 databases using this approach.
75 Prepare all statements before using them. Libecpg will
76 keep a cache of prepared statements and reuse a statement
77 if it gets executed again. If the cache runs full, libecpg
78 will free the least used statement.
81 Allow question mark as placeholder for compatibility
82 reasons. This used to be the default long ago.
85 Turn on autocommit of transactions. In this mode, each SQL
86 command is automatically committed unless it is inside an
87 explicit transaction block. In the default mode, commands are
88 committed only when EXEC SQL COMMIT is issued.
91 Print additional information including the version and the
95 Print the ecpg version and exit.
99 Show help about ecpg command line arguments, and exit.
103 When compiling the preprocessed C code files, the compiler needs to be
104 able to find the ECPG header files in the PostgreSQL include directory.
105 Therefore, you might have to use the -I option when invoking the
106 compiler (e.g., -I/usr/local/pgsql/include).
108 Programs using C code with embedded SQL have to be linked against the
109 libecpg library, for example using the linker options
110 -L/usr/local/pgsql/lib -lecpg.
112 The value of either of these directories that is appropriate for the
113 installation can be found out using pg_config.
117 If you have an embedded SQL C source file named prog1.pgc, you can
118 create an executable program using the following sequence of commands:
120 cc -I/usr/local/pgsql/include -c prog1.c
121 cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg