codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ecpg</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-dropuser.html" title="dropuser" /><link rel="next" href="app-pgamcheck.html" title="pg_amcheck" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">ecpg</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-dropuser.html" title="dropuser">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgamcheck.html" title="pg_amcheck">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-ECPG"><div class="titlepage"></div><a id="id-1.9.4.8.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">ecpg</span></span></h2><p><span class="application">ecpg</span> — embedded SQL C preprocessor</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.8.4.1"><code class="command">ecpg</code> [<em class="replaceable"><code>option</code></em>...] <em class="replaceable"><code>file</code></em>... </p></div></div><div class="refsect1" id="APP-ECPG-DESCRIPTION"><h2>Description</h2><p>3 <code class="command">ecpg</code> is the embedded SQL preprocessor for C4 programs. It converts C programs with embedded SQL statements to5 normal C code by replacing the SQL invocations with special6 function calls. The output files can then be processed with any C7 compiler tool chain.8 </p><p>9 <code class="command">ecpg</code> will convert each input file given on the10 command line to the corresponding C output file. If an input file11 name does not have any extension, <code class="filename">.pgc</code> is12 assumed. The file's extension will be replaced13 by <code class="filename">.c</code> to construct the output file name.14 But the output file name can be overridden using the15 <code class="option">-o</code> option.16 </p><p>17 If an input file name is just <code class="literal">-</code>,18 <code class="command">ecpg</code> reads the program from standard input19 (and writes to standard output, unless that is overridden20 with <code class="option">-o</code>).21 </p><p>22 This reference page does not describe the embedded SQL language.23 See <a class="xref" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Chapter 36</a> for more information on that topic.24 </p></div><div class="refsect1" id="id-1.9.4.8.6"><h2>Options</h2><p>25 <code class="command">ecpg</code> accepts the following command-line26 arguments:27 28 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-c</code></span></dt><dd><p>29 Automatically generate certain C code from SQL code. Currently, this30 works for <code class="literal">EXEC SQL TYPE</code>.31 </p></dd><dt><span class="term"><code class="option">-C <em class="replaceable"><code>mode</code></em></code></span></dt><dd><p>32 Set a compatibility mode. <em class="replaceable"><code>mode</code></em> can33 be <code class="literal">INFORMIX</code>,34 <code class="literal">INFORMIX_SE</code>, or <code class="literal">ORACLE</code>.35 </p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>symbol</code></em>[=<em class="replaceable"><code>value</code></em>]</code></span></dt><dd><p>36 Define a preprocessor symbol, equivalently to the <code class="command">EXEC SQL37 DEFINE</code> directive. If no <em class="replaceable"><code>value</code></em> is38 specified, the symbol is defined with the value <code class="literal">1</code>.39 </p></dd><dt><span class="term"><code class="option">-h</code></span></dt><dd><p>40 Process header files. When this option is specified, the output file41 extension becomes <code class="literal">.h</code> not <code class="literal">.c</code>,42 and the default input file extension is <code class="literal">.pgh</code>43 not <code class="literal">.pgc</code>. Also, the <code class="option">-c</code> option is44 forced on.45 </p></dd><dt><span class="term"><code class="option">-i</code></span></dt><dd><p>46 Parse system include files as well.47 </p></dd><dt><span class="term"><code class="option">-I <em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>48 Specify an additional include path, used to find files included49 via <code class="literal">EXEC SQL INCLUDE</code>. Defaults are50 <code class="filename">.</code> (current directory),51 <code class="filename">/usr/local/include</code>, the52 <span class="productname">PostgreSQL</span> include directory which53 is defined at compile time (default:54 <code class="filename">/usr/local/pgsql/include</code>), and55 <code class="filename">/usr/include</code>, in that order.56 </p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>57 Specifies that <code class="command">ecpg</code> should write all58 its output to the given <em class="replaceable"><code>filename</code></em>.59 Write <code class="literal">-o -</code> to send all output to standard output.60 </p></dd><dt><span class="term"><code class="option">-r <em class="replaceable"><code>option</code></em></code></span></dt><dd><p>61 Selects run-time behavior. <em class="replaceable"><code>Option</code></em> can be62 one of the following:63 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">no_indicator</code></span></dt><dd><p>64 Do not use indicators but instead use special values to represent65 null values. Historically there have been databases using this approach.66 </p></dd><dt><span class="term"><code class="option">prepare</code></span></dt><dd><p>67 Prepare all statements before using them. Libecpg will keep a cache of68 prepared statements and reuse a statement if it gets executed again. If the69 cache runs full, libecpg will free the least used statement.70 </p></dd><dt><span class="term"><code class="option">questionmarks</code></span></dt><dd><p>71 Allow question mark as placeholder for compatibility reasons.72 This used to be the default long ago.73 </p></dd></dl></div></dd><dt><span class="term"><code class="option">-t</code></span></dt><dd><p>74 Turn on autocommit of transactions. In this mode, each SQL command is75 automatically committed unless it is inside an explicit76 transaction block. In the default mode, commands are committed77 only when <code class="command">EXEC SQL COMMIT</code> is issued.78 </p></dd><dt><span class="term"><code class="option">-v</code></span></dt><dd><p>79 Print additional information including the version and the80 "include" path.81 </p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>82 Print the <span class="application">ecpg</span> version and exit.83 </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>84 Show help about <span class="application">ecpg</span> command line85 arguments, and exit.86 </p></dd></dl></div><p>87 </p></div><div class="refsect1" id="id-1.9.4.8.7"><h2>Notes</h2><p>88 When compiling the preprocessed C code files, the compiler needs to89 be able to find the <span class="application">ECPG</span> header files in the90 <span class="productname">PostgreSQL</span> include directory. Therefore, you might91 have to use the <code class="option">-I</code> option when invoking the compiler92 (e.g., <code class="literal">-I/usr/local/pgsql/include</code>).93 </p><p>94 Programs using C code with embedded SQL have to be linked against95 the <code class="filename">libecpg</code> library, for example using the96 linker options <code class="literal">-L/usr/local/pgsql/lib -lecpg</code>.97 </p><p>98 The value of either of these directories that is appropriate for99 the installation can be found out using <a class="xref" href="app-pgconfig.html" title="pg_config"><span class="refentrytitle"><span class="application">pg_config</span></span></a>.100 </p></div><div class="refsect1" id="id-1.9.4.8.8"><h2>Examples</h2><p>101 If you have an embedded SQL C source file named102 <code class="filename">prog1.pgc</code>, you can create an executable103 program using the following sequence of commands:104</p><pre class="programlisting">105ecpg prog1.pgc106cc -I/usr/local/pgsql/include -c prog1.c107cc -o prog1 prog1.o -L/usr/local/pgsql/lib -lecpg108</pre></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-dropuser.html" title="dropuser">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgamcheck.html" title="pg_amcheck">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">dropuser</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_amcheck</span></td></tr></table></div></body></html>