OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / doc / postgresql / html / app-ecpg.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >ecpg</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
9 REV="MADE"
10 HREF="mailto:pgsql-docs@postgresql.org"><LINK
11 REL="HOME"
12 TITLE="PostgreSQL 7.4.1 Documentation"
13 HREF="index.html"><LINK
14 REL="UP"
15 TITLE="PostgreSQL Client Applications"
16 HREF="reference-client.html"><LINK
17 REL="PREVIOUS"
18 TITLE="dropuser"
19 HREF="app-dropuser.html"><LINK
20 REL="NEXT"
21 TITLE="pg_config"
22 HREF="app-pgconfig.html"><LINK
23 REL="STYLESHEET"
24 TYPE="text/css"
25 HREF="stylesheet.css"><META
26 NAME="creation"
27 CONTENT="2003-12-22T03:48:47"></HEAD
28 ><BODY
29 CLASS="REFENTRY"
30 ><DIV
31 CLASS="NAVHEADER"
32 ><TABLE
33 SUMMARY="Header navigation table"
34 WIDTH="100%"
35 BORDER="0"
36 CELLPADDING="0"
37 CELLSPACING="0"
38 ><TR
39 ><TH
40 COLSPAN="5"
41 ALIGN="center"
42 VALIGN="bottom"
43 >PostgreSQL 7.4.1 Documentation</TH
44 ></TR
45 ><TR
46 ><TD
47 WIDTH="10%"
48 ALIGN="left"
49 VALIGN="top"
50 ><A
51 HREF="app-dropuser.html"
52 ACCESSKEY="P"
53 >Prev</A
54 ></TD
55 ><TD
56 WIDTH="10%"
57 ALIGN="left"
58 VALIGN="top"
59 ><A
60 HREF="app-dropuser.html"
61 >Fast Backward</A
62 ></TD
63 ><TD
64 WIDTH="60%"
65 ALIGN="center"
66 VALIGN="bottom"
67 ></TD
68 ><TD
69 WIDTH="10%"
70 ALIGN="right"
71 VALIGN="top"
72 ><A
73 HREF="app-pgconfig.html"
74 >Fast Forward</A
75 ></TD
76 ><TD
77 WIDTH="10%"
78 ALIGN="right"
79 VALIGN="top"
80 ><A
81 HREF="app-pgconfig.html"
82 ACCESSKEY="N"
83 >Next</A
84 ></TD
85 ></TR
86 ></TABLE
87 ><HR
88 ALIGN="LEFT"
89 WIDTH="100%"></DIV
90 ><H1
91 ><A
92 NAME="APP-ECPG"
93 ></A
94 ><SPAN
95 CLASS="APPLICATION"
96 >ecpg</SPAN
97 ></H1
98 ><DIV
99 CLASS="REFNAMEDIV"
100 ><A
101 NAME="AEN44204"
102 ></A
103 ><H2
104 >Name</H2
105 ><SPAN
106 CLASS="APPLICATION"
107 >ecpg</SPAN
108 >&nbsp;--&nbsp;embedded SQL C preprocessor</DIV
109 ><A
110 NAME="AEN44208"
111 ></A
112 ><DIV
113 CLASS="REFSYNOPSISDIV"
114 ><A
115 NAME="AEN44210"
116 ></A
117 ><H2
118 >Synopsis</H2
119 ><P
120 ><TT
121 CLASS="COMMAND"
122 >ecpg</TT
123 > [<VAR
124 CLASS="REPLACEABLE"
125 >option</VAR
126 >...]  <VAR
127 CLASS="REPLACEABLE"
128 >file</VAR
129 >... </P
130 ></DIV
131 ><DIV
132 CLASS="REFSECT1"
133 ><A
134 NAME="APP-ECPG-DESCRIPTION"
135 ></A
136 ><H2
137 >Description</H2
138 ><P
139 >   <TT
140 CLASS="COMMAND"
141 >ecpg</TT
142 > is the embedded SQL preprocessor for C
143    programs.  It converts C programs with embedded SQL statements to
144    normal C code by replacing the SQL invocations with special
145    function calls.  The output files can then be processed with any C
146    compiler tool chain.
147   </P
148 ><P
149 >   <TT
150 CLASS="COMMAND"
151 >ecpg</TT
152 > will convert each input file given on the
153    command line to the corresponding C output file.  Input files
154    preferably have the extension <TT
155 CLASS="FILENAME"
156 >.pgc</TT
157 >, in which
158    case the extension will be replaced by <TT
159 CLASS="FILENAME"
160 >.c</TT
161 > to
162    determine the output file name.  If the extension of the input file
163    is not <TT
164 CLASS="FILENAME"
165 >.pgc</TT
166 >, then the output file name is
167    computed by appending <TT
168 CLASS="LITERAL"
169 >.c</TT
170 > to the full file name.
171    The output file name can also be overridden using the
172    <VAR
173 CLASS="OPTION"
174 >-o</VAR
175 > option.
176   </P
177 ><P
178 >   This reference page does not describe the embedded SQL language.
179    See <A
180 HREF="ecpg.html"
181 >Chapter 30</A
182 > for more information on that topic.
183   </P
184 ></DIV
185 ><DIV
186 CLASS="REFSECT1"
187 ><A
188 NAME="AEN44230"
189 ></A
190 ><H2
191 >Options</H2
192 ><P
193 >   <TT
194 CLASS="COMMAND"
195 >ecpg</TT
196 > accepts the following command-line
197    arguments:
198
199    <P
200 ></P
201 ></P><DIV
202 CLASS="VARIABLELIST"
203 ><DL
204 ><DT
205 ><VAR
206 CLASS="OPTION"
207 >-c</VAR
208 ></DT
209 ><DD
210 ><P
211 >       Automatically generate certain C code from SQL code.  Currently, this
212        works for <TT
213 CLASS="LITERAL"
214 >EXEC SQL TYPE</TT
215 >.
216       </P
217 ></DD
218 ><DT
219 ><VAR
220 CLASS="OPTION"
221 >-C <VAR
222 CLASS="REPLACEABLE"
223 >mode</VAR
224 ></VAR
225 ></DT
226 ><DD
227 ><P
228 >       Set a compatibility mode.  <VAR
229 CLASS="REPLACEABLE"
230 >mode</VAR
231 > may
232        be <TT
233 CLASS="LITERAL"
234 >INFORMIX</TT
235 > or
236        <TT
237 CLASS="LITERAL"
238 >INFORMIX_SE</TT
239 >.
240       </P
241 ></DD
242 ><DT
243 ><VAR
244 CLASS="OPTION"
245 >-D <VAR
246 CLASS="REPLACEABLE"
247 >symbol</VAR
248 ></VAR
249 ></DT
250 ><DD
251 ><P
252 >       Define a C preprocessor symbol.
253       </P
254 ></DD
255 ><DT
256 ><VAR
257 CLASS="OPTION"
258 >-i</VAR
259 ></DT
260 ><DD
261 ><P
262 >       Parse system include files as well.
263       </P
264 ></DD
265 ><DT
266 ><VAR
267 CLASS="OPTION"
268 >-I <VAR
269 CLASS="REPLACEABLE"
270 >directory</VAR
271 ></VAR
272 ></DT
273 ><DD
274 ><P
275 >       Specify an additional include path, used to find files included
276        via <TT
277 CLASS="LITERAL"
278 >EXEC SQL INCLUDE</TT
279 >.  Defaults are
280        <TT
281 CLASS="FILENAME"
282 >.</TT
283 > (current directory),
284        <TT
285 CLASS="FILENAME"
286 >/usr/local/include</TT
287 >, the
288        <SPAN
289 CLASS="PRODUCTNAME"
290 >PostgreSQL</SPAN
291 > include directory which
292        is defined at compile time (default:
293        <TT
294 CLASS="FILENAME"
295 >/usr/local/pgsql/include</TT
296 >), and
297        <TT
298 CLASS="FILENAME"
299 >/usr/include</TT
300 >, in that order.
301       </P
302 ></DD
303 ><DT
304 ><VAR
305 CLASS="OPTION"
306 >-o <VAR
307 CLASS="REPLACEABLE"
308 >filename</VAR
309 ></VAR
310 ></DT
311 ><DD
312 ><P
313 >       Specifies that <TT
314 CLASS="COMMAND"
315 >ecpg</TT
316 > should write all
317        its output to the given <VAR
318 CLASS="REPLACEABLE"
319 >filename</VAR
320 >.
321       </P
322 ></DD
323 ><DT
324 ><VAR
325 CLASS="OPTION"
326 >-r <VAR
327 CLASS="REPLACEABLE"
328 >option</VAR
329 ></VAR
330 ></DT
331 ><DD
332 ><P
333 >       Selects a run-time behavior.  Currently,
334        <VAR
335 CLASS="REPLACEABLE"
336 >option</VAR
337 > can only be
338        <TT
339 CLASS="LITERAL"
340 >no_indicator</TT
341 >.
342       </P
343 ></DD
344 ><DT
345 ><VAR
346 CLASS="OPTION"
347 >-t</VAR
348 ></DT
349 ><DD
350 ><P
351 >       Turn on autocommit of transactions. In this mode, each SQL command is
352        automatically committed unless it is inside an explicit
353        transaction block. In the default mode, commands are committed
354        only when <TT
355 CLASS="COMMAND"
356 >EXEC SQL COMMIT</TT
357 > is issued.
358       </P
359 ></DD
360 ><DT
361 ><VAR
362 CLASS="OPTION"
363 >-v</VAR
364 ></DT
365 ><DD
366 ><P
367 >       Print additional information including the version and the
368        include path.
369       </P
370 ></DD
371 ><DT
372 ><VAR
373 CLASS="OPTION"
374 >--help</VAR
375 ></DT
376 ><DD
377 ><P
378 >       Show a brief summary of the command usage, then exit.
379       </P
380 ></DD
381 ><DT
382 ><VAR
383 CLASS="OPTION"
384 >--version</VAR
385 ></DT
386 ><DD
387 ><P
388 >       Output version information, then exit.
389       </P
390 ></DD
391 ></DL
392 ></DIV
393 ><P>
394   </P
395 ></DIV
396 ><DIV
397 CLASS="REFSECT1"
398 ><A
399 NAME="AEN44310"
400 ></A
401 ><H2
402 >Notes</H2
403 ><P
404 >   When compiling the preprocessed C code files, the compiler needs to
405    be able to find the <SPAN
406 CLASS="APPLICATION"
407 >ECPG</SPAN
408 > header files in the
409    <SPAN
410 CLASS="PRODUCTNAME"
411 >PostgreSQL</SPAN
412 > include directory.  Therefore, one might
413    have to use the <VAR
414 CLASS="OPTION"
415 >-I</VAR
416 > option when invoking the compiler
417    (e.g., <TT
418 CLASS="LITERAL"
419 >-I/usr/local/pgsql/include</TT
420 >).
421   </P
422 ><P
423 >   Programs using C code with embedded SQL have to be linked against
424    the <TT
425 CLASS="FILENAME"
426 >libecpg</TT
427 > library, for example using the
428    linker options <TT
429 CLASS="LITERAL"
430 >-L/usr/local/pgsql/lib -lecpg</TT
431 >.
432   </P
433 ><P
434 >   The value of either of these directories that is appropriate for
435    the installation can be found out using <A
436 HREF="app-pgconfig.html"
437 >pg_config</A
438 >.
439   </P
440 ></DIV
441 ><DIV
442 CLASS="REFSECT1"
443 ><A
444 NAME="AEN44322"
445 ></A
446 ><H2
447 >Examples</H2
448 ><P
449 >   If you have an embedded SQL C source file named
450    <TT
451 CLASS="FILENAME"
452 >prog1.pgc</TT
453 >, you can create an executable
454    program using the following sequence of commands:
455 </P><PRE
456 CLASS="PROGRAMLISTING"
457 >ecpg prog1.pgc
458 cc -I/usr/local/pgsql/include -c prog1.c
459 cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg</PRE
460 ><P>
461   </P
462 ></DIV
463 ><DIV
464 CLASS="NAVFOOTER"
465 ><HR
466 ALIGN="LEFT"
467 WIDTH="100%"><TABLE
468 SUMMARY="Footer navigation table"
469 WIDTH="100%"
470 BORDER="0"
471 CELLPADDING="0"
472 CELLSPACING="0"
473 ><TR
474 ><TD
475 WIDTH="33%"
476 ALIGN="left"
477 VALIGN="top"
478 ><A
479 HREF="app-dropuser.html"
480 ACCESSKEY="P"
481 >Prev</A
482 ></TD
483 ><TD
484 WIDTH="34%"
485 ALIGN="center"
486 VALIGN="top"
487 ><A
488 HREF="index.html"
489 ACCESSKEY="H"
490 >Home</A
491 ></TD
492 ><TD
493 WIDTH="33%"
494 ALIGN="right"
495 VALIGN="top"
496 ><A
497 HREF="app-pgconfig.html"
498 ACCESSKEY="N"
499 >Next</A
500 ></TD
501 ></TR
502 ><TR
503 ><TD
504 WIDTH="33%"
505 ALIGN="left"
506 VALIGN="top"
507 ><SPAN
508 CLASS="APPLICATION"
509 >dropuser</SPAN
510 ></TD
511 ><TD
512 WIDTH="34%"
513 ALIGN="center"
514 VALIGN="top"
515 ><A
516 HREF="reference-client.html"
517 ACCESSKEY="U"
518 >Up</A
519 ></TD
520 ><TD
521 WIDTH="33%"
522 ALIGN="right"
523 VALIGN="top"
524 >pg_config</TD
525 ></TR
526 ></TABLE
527 ></DIV
528 ></BODY
529 ></HTML
530 >