Make LC_COLLATE and LC_CTYPE database-level settings. Collation and
[PostgreSQL.git] / doc / src / sgml / ref / ecpg-ref.sgml
blob62b0219f71ab600e88738565cf215f078de5f278
1 <!--
2 $PostgreSQL$
3 PostgreSQL documentation
4 -->
6 <refentry id="APP-ECPG">
7 <refmeta>
8 <refentrytitle><application>ecpg</application></refentrytitle>
9 <manvolnum>1</manvolnum>
10 <refmiscinfo>Application</refmiscinfo>
11 </refmeta>
13 <refnamediv>
14 <refname><application>ecpg</application></refname>
15 <refpurpose>embedded SQL C preprocessor</refpurpose>
16 </refnamediv>
18 <indexterm zone="app-ecpg">
19 <primary>ecpg</primary>
20 </indexterm>
22 <refsynopsisdiv>
23 <cmdsynopsis>
24 <command>ecpg</command>
25 <arg choice="opt" rep="repeat"><replaceable>option</replaceable></arg>
26 <arg choice="plain" rep="repeat"><replaceable>file</replaceable></arg>
27 </cmdsynopsis>
28 </refsynopsisdiv>
31 <refsect1 id="APP-ECPG-description">
32 <title>Description</title>
34 <para>
35 <command>ecpg</command> is the embedded SQL preprocessor for C
36 programs. It converts C programs with embedded SQL statements to
37 normal C code by replacing the SQL invocations with special
38 function calls. The output files can then be processed with any C
39 compiler tool chain.
40 </para>
42 <para>
43 <command>ecpg</command> will convert each input file given on the
44 command line to the corresponding C output file. Input files
45 preferably have the extension <filename>.pgc</filename>, in which
46 case the extension will be replaced by <filename>.c</filename> to
47 determine the output file name. If the extension of the input file
48 is not <filename>.pgc</filename>, then the output file name is
49 computed by appending <literal>.c</literal> to the full file name.
50 The output file name can also be overridden using the
51 <option>-o</option> option.
52 </para>
54 <para>
55 This reference page does not describe the embedded SQL language.
56 See <xref linkend="ecpg"> for more information on that topic.
57 </para>
58 </refsect1>
61 <refsect1>
62 <title>Options</title>
64 <para>
65 <command>ecpg</command> accepts the following command-line
66 arguments:
68 <variablelist>
69 <varlistentry>
70 <term><option>-c</option></term>
71 <listitem>
72 <para>
73 Automatically generate certain C code from SQL code. Currently, this
74 works for <literal>EXEC SQL TYPE</literal>.
75 </para>
76 </listitem>
77 </varlistentry>
79 <varlistentry>
80 <term><option>-C <replaceable>mode</replaceable></option></term>
81 <listitem>
82 <para>
83 Set a compatibility mode. <replaceable>mode</replaceable> can
84 be <literal>INFORMIX</literal> or
85 <literal>INFORMIX_SE</literal>.
86 </para>
87 </listitem>
88 </varlistentry>
90 <varlistentry>
91 <term><option>-D <replaceable>symbol</replaceable></option></term>
92 <listitem>
93 <para>
94 Define a C preprocessor symbol.
95 </para>
96 </listitem>
97 </varlistentry>
99 <varlistentry>
100 <term><option>-i</option></term>
101 <listitem>
102 <para>
103 Parse system include files as well.
104 </para>
105 </listitem>
106 </varlistentry>
108 <varlistentry>
109 <term><option>-I <replaceable class="parameter">directory</replaceable></option></term>
110 <listitem>
111 <para>
112 Specify an additional include path, used to find files included
113 via <literal>EXEC SQL INCLUDE</literal>. Defaults are
114 <filename>.</filename> (current directory),
115 <filename>/usr/local/include</filename>, the
116 <productname>PostgreSQL</productname> include directory which
117 is defined at compile time (default:
118 <filename>/usr/local/pgsql/include</filename>), and
119 <filename>/usr/include</filename>, in that order.
120 </para>
121 </listitem>
122 </varlistentry>
124 <varlistentry>
125 <term><option>-o <replaceable>filename</replaceable></option></term>
126 <listitem>
127 <para>
128 Specifies that <command>ecpg</command> should write all
129 its output to the given <replaceable>filename</replaceable>.
130 </para>
131 </listitem>
132 </varlistentry>
134 <varlistentry>
135 <term><option>-r <replaceable>option</replaceable></option></term>
136 <listitem>
137 <para>
138 Selects a run-time behavior. Currently,
139 <replaceable>option</replaceable> can only be
140 <literal>no_indicator</literal>.
141 </para>
142 </listitem>
143 </varlistentry>
145 <varlistentry>
146 <term><option>-t</option></term>
147 <listitem>
148 <para>
149 Turn on autocommit of transactions. In this mode, each SQL command is
150 automatically committed unless it is inside an explicit
151 transaction block. In the default mode, commands are committed
152 only when <command>EXEC SQL COMMIT</command> is issued.
153 </para>
154 </listitem>
155 </varlistentry>
157 <varlistentry>
158 <term><option>-v</option></term>
159 <listitem>
160 <para>
161 Print additional information including the version and the
162 include path.
163 </para>
164 </listitem>
165 </varlistentry>
167 <varlistentry>
168 <term><option>--help</option></term>
169 <listitem>
170 <para>
171 Show a brief summary of the command usage, then exit.
172 </para>
173 </listitem>
174 </varlistentry>
176 <varlistentry>
177 <term><option>--version</option></term>
178 <listitem>
179 <para>
180 Output version information, then exit.
181 </para>
182 </listitem>
183 </varlistentry>
184 </variablelist>
185 </para>
186 </refsect1>
189 <refsect1>
190 <title>Notes</title>
192 <para>
193 When compiling the preprocessed C code files, the compiler needs to
194 be able to find the <application>ECPG</> header files in the
195 <productname>PostgreSQL</> include directory. Therefore, one might
196 have to use the <option>-I</> option when invoking the compiler
197 (e.g., <literal>-I/usr/local/pgsql/include</literal>).
198 </para>
200 <para>
201 Programs using C code with embedded SQL have to be linked against
202 the <filename>libecpg</filename> library, for example using the
203 linker options <literal>-L/usr/local/pgsql/lib -lecpg</literal>.
204 </para>
206 <para>
207 The value of either of these directories that is appropriate for
208 the installation can be found out using <xref
209 linkend="app-pgconfig">.
210 </para>
211 </refsect1>
214 <refsect1>
215 <title>Examples</title>
217 <para>
218 If you have an embedded SQL C source file named
219 <filename>prog1.pgc</filename>, you can create an executable
220 program using the following sequence of commands:
221 <programlisting>
222 ecpg prog1.pgc
223 cc -I/usr/local/pgsql/include -c prog1.c
224 cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg
225 </programlisting>
226 </para>
227 </refsect1>
229 </refentry>