summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/ecpg-library.html
blob: 79a243d62ee44bf4ba4d48d195e46dd5e324bd8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?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.11. Library Functions</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-process.html" title="36.10. Processing Embedded SQL Programs" /><link rel="next" href="ecpg-lo.html" title="36.12. Large Objects" /></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.11. Library Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg-process.html" title="36.10. Processing Embedded SQL Programs">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.7 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ecpg-lo.html" title="36.12. Large Objects">Next</a></td></tr></table><hr /></div><div class="sect1" id="ECPG-LIBRARY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">36.11. Library Functions</h2></div></div></div><p>
   The <code class="filename">libecpg</code> library primarily contains
   <span class="quote"><span class="quote">hidden</span></span> functions that are used to implement the
   functionality expressed by the embedded SQL commands.  But there
   are some functions that can usefully be called directly.  Note that
   this makes your code unportable.
  </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
     <code class="function">ECPGdebug(int <em class="replaceable"><code>on</code></em>, FILE
     *<em class="replaceable"><code>stream</code></em>)</code> turns on debug
     logging if called with the first argument non-zero. Debug logging
     is done on <em class="replaceable"><code>stream</code></em>.  The log contains
     all <acronym class="acronym">SQL</acronym> statements with all the input
     variables inserted, and the results from the
     <span class="productname">PostgreSQL</span> server. This can be very
     useful when searching for errors in your <acronym class="acronym">SQL</acronym>
     statements.
    </p><div class="note"><h3 class="title">Note</h3><p>
    On Windows, if the <span class="application">ecpg</span> libraries and an application are
    compiled with different flags, this function call will crash the
    application because the internal representation of the
    <code class="literal">FILE</code> pointers differ.  Specifically,
    multithreaded/single-threaded, release/debug, and static/dynamic
    flags should be the same for the library and all applications using
    that library.
    </p></div></li><li class="listitem"><p>
       <code class="function">ECPGget_PGconn(const char *<em class="replaceable"><code>connection_name</code></em>)
       </code> returns the library database connection handle identified by the given name.
       If <em class="replaceable"><code>connection_name</code></em> is set to <code class="literal">NULL</code>, the current
       connection handle is returned. If no connection handle can be identified, the function returns
       <code class="literal">NULL</code>. The returned connection handle can be used to call any other functions
       from <span class="application">libpq</span>, if necessary.
     </p><div class="note"><h3 class="title">Note</h3><p>
       It is a bad idea to manipulate database connection handles made from <span class="application">ecpg</span> directly
       with <span class="application">libpq</span> routines.
     </p></div></li><li class="listitem"><p>
       <code class="function">ECPGtransactionStatus(const char *<em class="replaceable"><code>connection_name</code></em>)</code>
       returns the current transaction status of the given connection identified by <em class="replaceable"><code>connection_name</code></em>.
       See <a class="xref" href="libpq-status.html" title="34.2. Connection Status Functions">Section 34.2</a> and libpq's <a class="xref" href="libpq-status.html#LIBPQ-PQTRANSACTIONSTATUS"><code class="function">PQtransactionStatus</code></a> for details about the returned status codes.
     </p></li><li class="listitem"><p>
     <code class="function">ECPGstatus(int <em class="replaceable"><code>lineno</code></em>,
     const char* <em class="replaceable"><code>connection_name</code></em>)</code>
     returns true if you are connected to a database and false if not.
     <em class="replaceable"><code>connection_name</code></em> can be <code class="literal">NULL</code>
     if a single connection is being used.
    </p></li></ul></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ecpg-process.html" title="36.10. Processing Embedded SQL Programs">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-lo.html" title="36.12. Large Objects">Next</a></td></tr><tr><td width="40%" align="left" valign="top">36.10. Processing Embedded SQL Programs </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.7 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 36.12. Large Objects</td></tr></table></div></body></html>