Current File : //usr/share/doc/postgresql-9.2.24/html/app-ecpg.html |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>ecpg</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.2.24 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="PostgreSQL Client Applications"
HREF="reference-client.html"><LINK
REL="PREVIOUS"
TITLE="dropuser"
HREF="app-dropuser.html"><LINK
REL="NEXT"
TITLE="pg_basebackup"
HREF="app-pgbasebackup.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2017-11-06T22:43:11"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.2.24 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="dropuser"
HREF="app-dropuser.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="reference-client.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="pg_basebackup"
HREF="app-pgbasebackup.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="APP-ECPG"
></A
><SPAN
CLASS="APPLICATION"
>ecpg</SPAN
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN81506"
></A
><H2
>Name</H2
><SPAN
CLASS="APPLICATION"
>ecpg</SPAN
> -- embedded SQL C preprocessor</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN81512"
></A
><H2
>Synopsis</H2
><P
><TT
CLASS="COMMAND"
>ecpg</TT
> [<TT
CLASS="REPLACEABLE"
><I
>option</I
></TT
>...] <TT
CLASS="REPLACEABLE"
><I
>file</I
></TT
>... </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="APP-ECPG-DESCRIPTION"
></A
><H2
>Description</H2
><P
> <TT
CLASS="COMMAND"
>ecpg</TT
> is the embedded SQL preprocessor for C
programs. It converts C programs with embedded SQL statements to
normal C code by replacing the SQL invocations with special
function calls. The output files can then be processed with any C
compiler tool chain.
</P
><P
> <TT
CLASS="COMMAND"
>ecpg</TT
> will convert each input file given on the
command line to the corresponding C output file. Input files
preferably have the extension <TT
CLASS="FILENAME"
>.pgc</TT
>.
The extension will be replaced by <TT
CLASS="FILENAME"
>.c</TT
> to
determine the output file name.
The output file name can also be overridden using the
<TT
CLASS="OPTION"
>-o</TT
> option.
</P
><P
> This reference page does not describe the embedded SQL language.
See <A
HREF="ecpg.html"
>Chapter 33</A
> for more information on that topic.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN81530"
></A
><H2
>Options</H2
><P
> <TT
CLASS="COMMAND"
>ecpg</TT
> accepts the following command-line
arguments:
<P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="OPTION"
>-c</TT
></DT
><DD
><P
> Automatically generate certain C code from SQL code. Currently, this
works for <TT
CLASS="LITERAL"
>EXEC SQL TYPE</TT
>.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-C <TT
CLASS="REPLACEABLE"
><I
>mode</I
></TT
></TT
></DT
><DD
><P
> Set a compatibility mode. <TT
CLASS="REPLACEABLE"
><I
>mode</I
></TT
> can
be <TT
CLASS="LITERAL"
>INFORMIX</TT
> or
<TT
CLASS="LITERAL"
>INFORMIX_SE</TT
>.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-D <TT
CLASS="REPLACEABLE"
><I
>symbol</I
></TT
></TT
></DT
><DD
><P
> Define a C preprocessor symbol.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-i</TT
></DT
><DD
><P
> Parse system include files as well.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-I <TT
CLASS="REPLACEABLE"
><I
>directory</I
></TT
></TT
></DT
><DD
><P
> Specify an additional include path, used to find files included
via <TT
CLASS="LITERAL"
>EXEC SQL INCLUDE</TT
>. Defaults are
<TT
CLASS="FILENAME"
>.</TT
> (current directory),
<TT
CLASS="FILENAME"
>/usr/local/include</TT
>, the
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> include directory which
is defined at compile time (default:
<TT
CLASS="FILENAME"
>/usr/local/pgsql/include</TT
>), and
<TT
CLASS="FILENAME"
>/usr/include</TT
>, in that order.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-o <TT
CLASS="REPLACEABLE"
><I
>filename</I
></TT
></TT
></DT
><DD
><P
> Specifies that <TT
CLASS="COMMAND"
>ecpg</TT
> should write all
its output to the given <TT
CLASS="REPLACEABLE"
><I
>filename</I
></TT
>.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-r <TT
CLASS="REPLACEABLE"
><I
>option</I
></TT
></TT
></DT
><DD
><P
> Selects run-time behavior. <TT
CLASS="REPLACEABLE"
><I
>Option</I
></TT
> can be
one of the following:
<P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="OPTION"
>no_indicator</TT
></DT
><DD
><P
> Do not use indicators but instead use special values to represent
null values. Historically there have been databases using this approach.
</P
></DD
><DT
><TT
CLASS="OPTION"
>prepare</TT
></DT
><DD
><P
> Prepare all statements before using them. Libecpg will keep a cache of
prepared statements and reuse a statement if it gets executed again. If the
cache runs full, libecpg will free the least used statement.
</P
></DD
><DT
><TT
CLASS="OPTION"
>questionmarks</TT
></DT
><DD
><P
> Allow question mark as placeholder for compatibility reasons.
This used to be the default long ago.
</P
></DD
></DL
></DIV
><P></P
></DD
><DT
><TT
CLASS="OPTION"
>-t</TT
></DT
><DD
><P
> Turn on autocommit of transactions. In this mode, each SQL command is
automatically committed unless it is inside an explicit
transaction block. In the default mode, commands are committed
only when <TT
CLASS="COMMAND"
>EXEC SQL COMMIT</TT
> is issued.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-v</TT
></DT
><DD
><P
> Print additional information including the version and the
"include" path.
</P
></DD
><DT
><TT
CLASS="OPTION"
>--version</TT
></DT
><DD
><P
> Print the <SPAN
CLASS="APPLICATION"
>ecpg</SPAN
> version and exit.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-?</TT
><BR><TT
CLASS="OPTION"
>--help</TT
></DT
><DD
><P
> Show help about <SPAN
CLASS="APPLICATION"
>ecpg</SPAN
> command line
arguments, and exit.
</P
></DD
></DL
></DIV
><P>
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN81629"
></A
><H2
>Notes</H2
><P
> When compiling the preprocessed C code files, the compiler needs to
be able to find the <SPAN
CLASS="APPLICATION"
>ECPG</SPAN
> header files in the
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> include directory. Therefore, you might
have to use the <TT
CLASS="OPTION"
>-I</TT
> option when invoking the compiler
(e.g., <TT
CLASS="LITERAL"
>-I/usr/local/pgsql/include</TT
>).
</P
><P
> Programs using C code with embedded SQL have to be linked against
the <TT
CLASS="FILENAME"
>libecpg</TT
> library, for example using the
linker options <TT
CLASS="LITERAL"
>-L/usr/local/pgsql/lib -lecpg</TT
>.
</P
><P
> The value of either of these directories that is appropriate for
the installation can be found out using <A
HREF="app-pgconfig.html"
>pg_config</A
>.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN81641"
></A
><H2
>Examples</H2
><P
> If you have an embedded SQL C source file named
<TT
CLASS="FILENAME"
>prog1.pgc</TT
>, you can create an executable
program using the following sequence of commands:
</P><PRE
CLASS="PROGRAMLISTING"
>ecpg prog1.pgc
cc -I/usr/local/pgsql/include -c prog1.c
cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg</PRE
><P></P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-dropuser.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-pgbasebackup.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><SPAN
CLASS="APPLICATION"
>dropuser</SPAN
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference-client.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>pg_basebackup</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>