1ECPG(1)                  PostgreSQL 10.7 Documentation                 ECPG(1)
2
3
4

NAME

6       ecpg - embedded SQL C preprocessor
7

SYNOPSIS

9       ecpg [option...] file...
10

DESCRIPTION

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.
16
17       ecpg will convert each input file given on the command line to the
18       corresponding C output file. Input files preferably have the extension
19       .pgc. The extension will be replaced by .c to determine the output file
20       name. The output file name can also be overridden using the -o option.
21
22       This reference page does not describe the embedded SQL language. See
23       Chapter 35 for more information on that topic.
24

OPTIONS

26       ecpg accepts the following command-line arguments:
27
28       -c
29           Automatically generate certain C code from SQL code. Currently,
30           this works for EXEC SQL TYPE.
31
32       -C mode
33           Set a compatibility mode.  mode can be INFORMIX or INFORMIX_SE.
34
35       -D symbol
36           Define a C preprocessor symbol.
37
38       -h
39           Parse a header file, this option includes option -c.
40
41       -i
42           Parse system include files as well.
43
44       -I directory
45           Specify an additional include path, used to find files included via
46           EXEC SQL INCLUDE. Defaults are .  (current directory),
47           /usr/local/include, the PostgreSQL include directory which is
48           defined at compile time (default: /usr/local/pgsql/include), and
49           /usr/include, in that order.
50
51       -o filename
52           Specifies that ecpg should write all its output to the given
53           filename.
54
55       -r option
56           Selects run-time behavior.  Option can be one of the following:
57
58           no_indicator
59               Do not use indicators but instead use special values to
60               represent null values. Historically there have been databases
61               using this approach.
62
63           prepare
64               Prepare all statements before using them. Libecpg will keep a
65               cache of prepared statements and reuse a statement if it gets
66               executed again. If the cache runs full, libecpg will free the
67               least used statement.
68
69           questionmarks
70               Allow question mark as placeholder for compatibility reasons.
71               This used to be the default long ago.
72
73       --regression
74           Run in regression testing mode.
75
76       -t
77           Turn on autocommit of transactions. In this mode, each SQL command
78           is automatically committed unless it is inside an explicit
79           transaction block. In the default mode, commands are committed only
80           when EXEC SQL COMMIT is issued.
81
82       -v
83           Print additional information including the version and the
84           "include" path.
85
86       --version
87           Print the ecpg version and exit.
88
89       -?
90       --help
91           Show help about ecpg command line arguments, and exit.
92

NOTES

94       When compiling the preprocessed C code files, the compiler needs to be
95       able to find the ECPG header files in the PostgreSQL include directory.
96       Therefore, you might have to use the -I option when invoking the
97       compiler (e.g., -I/usr/local/pgsql/include).
98
99       Programs using C code with embedded SQL have to be linked against the
100       libecpg library, for example using the linker options
101       -L/usr/local/pgsql/lib -lecpg.
102
103       The value of either of these directories that is appropriate for the
104       installation can be found out using pg_config(1).
105

EXAMPLES

107       If you have an embedded SQL C source file named prog1.pgc, you can
108       create an executable program using the following sequence of commands:
109
110           ecpg prog1.pgc
111           cc -I/usr/local/pgsql/include -c prog1.c
112           cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg
113
114
115
116
117PostgreSQL 10.7                      2019                              ECPG(1)
Impressum