1ECPG(1) PostgreSQL Client Applications ECPG(1)
2
3
4
6 ecpg - embedded SQL C preprocessor
7
8
10 ecpg [ option... ] file...
11
13 ecpg is the embedded SQL preprocessor for C programs. It converts C
14 programs with embedded SQL statements to normal C code by replacing the
15 SQL invocations with special function calls. The output files can then
16 be processed with any C compiler tool chain.
17
18 ecpg will convert each input file given on the command line to the cor‐
19 responding C output file. Input files preferably have the extension
20 .pgc, in which case the extension will be replaced by .c to determine
21 the output file name. If the extension of the input file is not .pgc,
22 then the output file name is computed by appending .c to the full file
23 name. The output file name can also be overridden using the -o option.
24
25 This reference page does not describe the embedded SQL language. See
26 in the documentation for more information on that topic.
27
29 ecpg accepts the following command-line arguments:
30
31 -c Automatically generate certain C code from SQL code. Currently,
32 this works for EXEC SQL TYPE.
33
34 -C mode
35 Set a compatibility mode. mode may be INFORMIX or INFORMIX_SE.
36
37 -D symbol
38 Define a C preprocessor symbol.
39
40 -i Parse system include files as well.
41
42 -I directory
43 Specify an additional include path, used to find files included
44 via EXEC SQL INCLUDE. Defaults are . (current directory),
45 /usr/local/include, the PostgreSQL include directory which is
46 defined at compile time (default: /usr/local/pgsql/include), and
47 /usr/include, in that order.
48
49 -o filename
50 Specifies that ecpg should write all its output to the given
51 filename.
52
53 -r option
54 Selects a run-time behavior. Currently, option can only be
55 no_indicator.
56
57 -t Turn on autocommit of transactions. In this mode, each SQL com‐
58 mand is automatically committed unless it is inside an explicit
59 transaction block. In the default mode, commands are committed
60 only when EXEC SQL COMMIT is issued.
61
62 -v Print additional information including the version and the
63 include path.
64
65 --help Show a brief summary of the command usage, then exit.
66
67 --version
68 Output version information, then exit.
69
71 When compiling the preprocessed C code files, the compiler needs to be
72 able to find the ECPG header files in the PostgreSQL include directory.
73 Therefore, one might have to use the -I option when invoking the com‐
74 piler (e.g., -I/usr/local/pgsql/include).
75
76 Programs using C code with embedded SQL have to be linked against the
77 libecpg library, for example using the linker options
78 -L/usr/local/pgsql/lib -lecpg.
79
80 The value of either of these directories that is appropriate for the
81 installation can be found out using pg_config(1).
82
84 If you have an embedded SQL C source file named prog1.pgc, you can cre‐
85 ate an executable program using the following sequence of commands:
86
87 ecpg prog1.pgc
88 cc -I/usr/local/pgsql/include -c prog1.c
89 cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg
90
91
92
93
94Application 2008-06-08 ECPG(1)