summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/ecpg-process.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/sgml/html/ecpg-process.html')
-rw-r--r--doc/src/sgml/html/ecpg-process.html68
1 files changed, 68 insertions, 0 deletions
diff --git a/doc/src/sgml/html/ecpg-process.html b/doc/src/sgml/html/ecpg-process.html
new file mode 100644
index 0000000..6bcd046
--- /dev/null
+++ b/doc/src/sgml/html/ecpg-process.html
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!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>36.10. Processing Embedded SQL Programs</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="ecpg-preproc.html" title="36.9. Preprocessor Directives" /><link rel="next" href="ecpg-library.html" title="36.11. Library Functions" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">36.10. Processing Embedded SQL Programs</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg-preproc.html" title="36.9. Preprocessor Directives">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Up</a></td><th width="60%" align="center">Chapter 36. <span class="application">ECPG</span> — Embedded <acronym class="acronym">SQL</acronym> in C</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ecpg-library.html" title="36.11. Library Functions">Next</a></td></tr></table><hr /></div><div class="sect1" id="ECPG-PROCESS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">36.10. Processing Embedded SQL Programs</h2></div></div></div><p>
+ Now that you have an idea how to form embedded SQL C programs, you
+ probably want to know how to compile them. Before compiling you
+ run the file through the embedded <acronym class="acronym">SQL</acronym>
+ <acronym class="acronym">C</acronym> preprocessor, which converts the
+ <acronym class="acronym">SQL</acronym> statements you used to special function
+ calls. After compiling, you must link with a special library that
+ contains the needed functions. These functions fetch information
+ from the arguments, perform the <acronym class="acronym">SQL</acronym> command using
+ the <span class="application">libpq</span> interface, and put the result
+ in the arguments specified for output.
+ </p><p>
+ The preprocessor program is called <code class="filename">ecpg</code> and is
+ included in a normal <span class="productname">PostgreSQL</span> installation.
+ Embedded SQL programs are typically named with an extension
+ <code class="filename">.pgc</code>. If you have a program file called
+ <code class="filename">prog1.pgc</code>, you can preprocess it by simply
+ calling:
+</p><pre class="programlisting">
+ecpg prog1.pgc
+</pre><p>
+ This will create a file called <code class="filename">prog1.c</code>. If
+ your input files do not follow the suggested naming pattern, you
+ can specify the output file explicitly using the
+ <code class="option">-o</code> option.
+ </p><p>
+ The preprocessed file can be compiled normally, for example:
+</p><pre class="programlisting">
+cc -c prog1.c
+</pre><p>
+ The generated C source files include header files from the
+ <span class="productname">PostgreSQL</span> installation, so if you installed
+ <span class="productname">PostgreSQL</span> in a location that is not searched by
+ default, you have to add an option such as
+ <code class="literal">-I/usr/local/pgsql/include</code> to the compilation
+ command line.
+ </p><p>
+ To link an embedded SQL program, you need to include the
+ <code class="filename">libecpg</code> library, like so:
+</p><pre class="programlisting">
+cc -o myprog prog1.o prog2.o ... -lecpg
+</pre><p>
+ Again, you might have to add an option like
+ <code class="literal">-L/usr/local/pgsql/lib</code> to that command line.
+ </p><p>
+ You can
+ use <code class="command">pg_config</code><a id="id-1.7.5.16.6.2" class="indexterm"></a>
+ or <code class="command">pkg-config</code><a id="id-1.7.5.16.6.4" class="indexterm"></a> with package name <code class="literal">libecpg</code> to
+ get the paths for your installation.
+ </p><p>
+ If you manage the build process of a larger project using
+ <span class="application">make</span>, it might be convenient to include
+ the following implicit rule to your makefiles:
+</p><pre class="programlisting">
+ECPG = ecpg
+
+%.c: %.pgc
+ $(ECPG) $&lt;
+</pre><p>
+ </p><p>
+ The complete syntax of the <code class="command">ecpg</code> command is
+ detailed in <a class="xref" href="app-ecpg.html" title="ecpg"><span class="refentrytitle"><span class="application">ecpg</span></span></a>.
+ </p><p>
+ The <span class="application">ecpg</span> library is thread-safe by
+ default. However, you might need to use some threading
+ command-line options to compile your client code.
+ </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ecpg-preproc.html" title="36.9. Preprocessor Directives">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-library.html" title="36.11. Library Functions">Next</a></td></tr><tr><td width="40%" align="left" valign="top">36.9. Preprocessor Directives </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 36.11. Library Functions</td></tr></table></div></body></html> \ No newline at end of file