]> begriffs open source - ai-pg/blob - full-docs/txt/app-ecpg.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / app-ecpg.txt
1
2 ecpg
3
4    ecpg — embedded SQL C preprocessor
5
6 Synopsis
7
8    ecpg [option...] file...
9
10 Description
11
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. 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.
22
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
25    -o).
26
27    This reference page does not describe the embedded SQL language. See
28    Chapter 34 for more information on that topic.
29
30 Options
31
32    ecpg accepts the following command-line arguments:
33
34    -c
35           Automatically generate certain C code from SQL code. Currently,
36           this works for EXEC SQL TYPE.
37
38    -C mode
39           Set a compatibility mode. mode can be INFORMIX, INFORMIX_SE, or
40           ORACLE.
41
42    -D symbol[=value]
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.
46
47    -h
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.
51
52    -i
53           Parse system include files as well.
54
55    -I directory
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.
61
62    -o filename
63           Specifies that ecpg should write all its output to the given
64           filename. Write -o - to send all output to standard output.
65
66    -r option
67           Selects run-time behavior. Option can be one of the following:
68
69         no_indicator
70                 Do not use indicators but instead use special values to
71                 represent null values. Historically there have been
72                 databases using this approach.
73
74         prepare
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.
79
80         questionmarks
81                 Allow question mark as placeholder for compatibility
82                 reasons. This used to be the default long ago.
83
84    -t
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.
89
90    -v
91           Print additional information including the version and the
92           "include" path.
93
94    --version
95           Print the ecpg version and exit.
96
97    -?
98           --help
99           Show help about ecpg command line arguments, and exit.
100
101 Notes
102
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).
107
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.
111
112    The value of either of these directories that is appropriate for the
113    installation can be found out using pg_config.
114
115 Examples
116
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:
119 ecpg prog1.pgc
120 cc -I/usr/local/pgsql/include -c prog1.c
121 cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg