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>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 16.3 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 <a href="#ECPG-LIBRARY" class="id_link">#</a></h2></div></div></div><p>3 The <code class="filename">libecpg</code> library primarily contains4 <span class="quote">“<span class="quote">hidden</span>”</span> functions that are used to implement the5 functionality expressed by the embedded SQL commands. But there6 are some functions that can usefully be called directly. Note that7 this makes your code unportable.8 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>9 <code class="function">ECPGdebug(int <em class="replaceable"><code>on</code></em>, FILE10 *<em class="replaceable"><code>stream</code></em>)</code> turns on debug11 logging if called with the first argument non-zero. Debug logging12 is done on <em class="replaceable"><code>stream</code></em>. The log contains13 all <acronym class="acronym">SQL</acronym> statements with all the input14 variables inserted, and the results from the15 <span class="productname">PostgreSQL</span> server. This can be very16 useful when searching for errors in your <acronym class="acronym">SQL</acronym>17 statements.18 </p><div class="note"><h3 class="title">Note</h3><p>19 On Windows, if the <span class="application">ecpg</span> libraries and an application are20 compiled with different flags, this function call will crash the21 application because the internal representation of the22 <code class="literal">FILE</code> pointers differ. Specifically,23 multithreaded/single-threaded, release/debug, and static/dynamic24 flags should be the same for the library and all applications using25 that library.26 </p></div></li><li class="listitem"><p>27 <code class="function">ECPGget_PGconn(const char *<em class="replaceable"><code>connection_name</code></em>)28 </code> returns the library database connection handle identified by the given name.29 If <em class="replaceable"><code>connection_name</code></em> is set to <code class="literal">NULL</code>, the current30 connection handle is returned. If no connection handle can be identified, the function returns31 <code class="literal">NULL</code>. The returned connection handle can be used to call any other functions32 from <span class="application">libpq</span>, if necessary.33 </p><div class="note"><h3 class="title">Note</h3><p>34 It is a bad idea to manipulate database connection handles made from <span class="application">ecpg</span> directly35 with <span class="application">libpq</span> routines.36 </p></div></li><li class="listitem"><p>37 <code class="function">ECPGtransactionStatus(const char *<em class="replaceable"><code>connection_name</code></em>)</code>38 returns the current transaction status of the given connection identified by <em class="replaceable"><code>connection_name</code></em>.39 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.40 </p></li><li class="listitem"><p>41 <code class="function">ECPGstatus(int <em class="replaceable"><code>lineno</code></em>,42 const char* <em class="replaceable"><code>connection_name</code></em>)</code>43 returns true if you are connected to a database and false if not.44 <em class="replaceable"><code>connection_name</code></em> can be <code class="literal">NULL</code>45 if a single connection is being used.46 </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 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 36.12. Large Objects</td></tr></table></div></body></html>