summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/ecpg.html
blob: aa8e8339518067f1177dd4a76ce16e24ef50bed4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
<?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>Chapter 36. ECPG — Embedded SQL in C</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="lo-examplesect.html" title="35.5. Example Program" /><link rel="next" href="ecpg-concept.html" title="36.1. The Concept" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Chapter 36. <span class="application">ECPG</span> — Embedded <acronym class="acronym">SQL</acronym> in C</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="lo-examplesect.html" title="35.5. Example Program">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="client-interfaces.html" title="Part IV. Client Interfaces">Up</a></td><th width="60%" align="center">Part IV. Client Interfaces</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.6 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ecpg-concept.html" title="36.1. The Concept">Next</a></td></tr></table><hr /></div><div class="chapter" id="ECPG"><div class="titlepage"><div><div><h2 class="title">Chapter 36. <span class="application">ECPG</span> — Embedded <acronym class="acronym">SQL</acronym> in C</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="ecpg-concept.html">36.1. The Concept</a></span></dt><dt><span class="sect1"><a href="ecpg-connect.html">36.2. Managing Database Connections</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-connect.html#ECPG-CONNECTING">36.2.1. Connecting to the Database Server</a></span></dt><dt><span class="sect2"><a href="ecpg-connect.html#ECPG-SET-CONNECTION">36.2.2. Choosing a Connection</a></span></dt><dt><span class="sect2"><a href="ecpg-connect.html#ECPG-DISCONNECT">36.2.3. Closing a Connection</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-commands.html">36.3. Running SQL Commands</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-commands.html#ECPG-EXECUTING">36.3.1. Executing SQL Statements</a></span></dt><dt><span class="sect2"><a href="ecpg-commands.html#ECPG-CURSORS">36.3.2. Using Cursors</a></span></dt><dt><span class="sect2"><a href="ecpg-commands.html#ECPG-TRANSACTIONS">36.3.3. Managing Transactions</a></span></dt><dt><span class="sect2"><a href="ecpg-commands.html#ECPG-PREPARED">36.3.4. Prepared Statements</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-variables.html">36.4. Using Host Variables</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-variables.html#ECPG-VARIABLES-OVERVIEW">36.4.1. Overview</a></span></dt><dt><span class="sect2"><a href="ecpg-variables.html#ECPG-DECLARE-SECTIONS">36.4.2. Declare Sections</a></span></dt><dt><span class="sect2"><a href="ecpg-variables.html#ECPG-RETRIEVING">36.4.3. Retrieving Query Results</a></span></dt><dt><span class="sect2"><a href="ecpg-variables.html#ECPG-VARIABLES-TYPE-MAPPING">36.4.4. Type Mapping</a></span></dt><dt><span class="sect2"><a href="ecpg-variables.html#ECPG-VARIABLES-NONPRIMITIVE-SQL">36.4.5. Handling Nonprimitive SQL Data Types</a></span></dt><dt><span class="sect2"><a href="ecpg-variables.html#ECPG-INDICATORS">36.4.6. Indicators</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-dynamic.html">36.5. Dynamic SQL</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-dynamic.html#ECPG-DYNAMIC-WITHOUT-RESULT">36.5.1. Executing Statements without a Result Set</a></span></dt><dt><span class="sect2"><a href="ecpg-dynamic.html#ECPG-DYNAMIC-INPUT">36.5.2. Executing a Statement with Input Parameters</a></span></dt><dt><span class="sect2"><a href="ecpg-dynamic.html#ECPG-DYNAMIC-WITH-RESULT">36.5.3. Executing a Statement with a Result Set</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-pgtypes.html">36.6. pgtypes Library</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-pgtypes.html#ECPG-PGTYPES-CSTRINGS">36.6.1. Character Strings</a></span></dt><dt><span class="sect2"><a href="ecpg-pgtypes.html#ECPG-PGTYPES-NUMERIC">36.6.2. The numeric Type</a></span></dt><dt><span class="sect2"><a href="ecpg-pgtypes.html#ECPG-PGTYPES-DATE">36.6.3. The date Type</a></span></dt><dt><span class="sect2"><a href="ecpg-pgtypes.html#ECPG-PGTYPES-TIMESTAMP">36.6.4. The timestamp Type</a></span></dt><dt><span class="sect2"><a href="ecpg-pgtypes.html#ECPG-PGTYPES-INTERVAL">36.6.5. The interval Type</a></span></dt><dt><span class="sect2"><a href="ecpg-pgtypes.html#ECPG-PGTYPES-DECIMAL">36.6.6. The decimal Type</a></span></dt><dt><span class="sect2"><a href="ecpg-pgtypes.html#ECPG-PGTYPES-ERRNO">36.6.7. errno Values of pgtypeslib</a></span></dt><dt><span class="sect2"><a href="ecpg-pgtypes.html#ECPG-PGTYPES-CONSTANTS">36.6.8. Special Constants of pgtypeslib</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-descriptors.html">36.7. Using Descriptor Areas</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-descriptors.html#ECPG-NAMED-DESCRIPTORS">36.7.1. Named SQL Descriptor Areas</a></span></dt><dt><span class="sect2"><a href="ecpg-descriptors.html#ECPG-SQLDA-DESCRIPTORS">36.7.2. SQLDA Descriptor Areas</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-errors.html">36.8. Error Handling</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-WHENEVER">36.8.1. Setting Callbacks</a></span></dt><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-SQLCA">36.8.2. sqlca</a></span></dt><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-SQLSTATE-SQLCODE">36.8.3. <code class="literal">SQLSTATE</code> vs. <code class="literal">SQLCODE</code></a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-preproc.html">36.9. Preprocessor Directives</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-preproc.html#ECPG-INCLUDE">36.9.1. Including Files</a></span></dt><dt><span class="sect2"><a href="ecpg-preproc.html#ECPG-DEFINE">36.9.2. The define and undef Directives</a></span></dt><dt><span class="sect2"><a href="ecpg-preproc.html#ECPG-IFDEF">36.9.3. ifdef, ifndef, elif, else, and endif Directives</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-process.html">36.10. Processing Embedded SQL Programs</a></span></dt><dt><span class="sect1"><a href="ecpg-library.html">36.11. Library Functions</a></span></dt><dt><span class="sect1"><a href="ecpg-lo.html">36.12. Large Objects</a></span></dt><dt><span class="sect1"><a href="ecpg-cpp.html">36.13. <acronym class="acronym">C++</acronym> Applications</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-cpp.html#ECPG-CPP-SCOPE">36.13.1. Scope for Host Variables</a></span></dt><dt><span class="sect2"><a href="ecpg-cpp.html#ECPG-CPP-AND-C">36.13.2. C++ Application Development with External C Module</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-sql-commands.html">36.14. Embedded SQL Commands</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="ecpg-sql-allocate-descriptor.html">ALLOCATE DESCRIPTOR</a></span><span class="refpurpose"> — allocate an SQL descriptor area</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-connect.html">CONNECT</a></span><span class="refpurpose"> — establish a database connection</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-deallocate-descriptor.html">DEALLOCATE DESCRIPTOR</a></span><span class="refpurpose"> — deallocate an SQL descriptor area</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-declare.html">DECLARE</a></span><span class="refpurpose"> — define a cursor</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-declare-statement.html">DECLARE STATEMENT</a></span><span class="refpurpose"> — declare SQL statement identifier</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-describe.html">DESCRIBE</a></span><span class="refpurpose"> — obtain information about a prepared statement or result set</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-disconnect.html">DISCONNECT</a></span><span class="refpurpose"> — terminate a database connection</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-execute-immediate.html">EXECUTE IMMEDIATE</a></span><span class="refpurpose"> — dynamically prepare and execute a statement</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-get-descriptor.html">GET DESCRIPTOR</a></span><span class="refpurpose"> — get information from an SQL descriptor area</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-open.html">OPEN</a></span><span class="refpurpose"> — open a dynamic cursor</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-prepare.html">PREPARE</a></span><span class="refpurpose"> — prepare a statement for execution</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-set-autocommit.html">SET AUTOCOMMIT</a></span><span class="refpurpose"> — set the autocommit behavior of the current session</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-set-connection.html">SET CONNECTION</a></span><span class="refpurpose"> — select a database connection</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-set-descriptor.html">SET DESCRIPTOR</a></span><span class="refpurpose"> — set information in an SQL descriptor area</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-type.html">TYPE</a></span><span class="refpurpose"> — define a new data type</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-var.html">VAR</a></span><span class="refpurpose"> — define a variable</span></dt><dt><span class="refentrytitle"><a href="ecpg-sql-whenever.html">WHENEVER</a></span><span class="refpurpose"> — specify the action to be taken when an SQL statement causes a specific class condition to be raised</span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-informix-compat.html">36.15. <span class="productname">Informix</span> Compatibility Mode</a></span></dt><dd><dl><dt><span class="sect2"><a href="ecpg-informix-compat.html#ECPG-INFORMIX-TYPES">36.15.1. Additional Types</a></span></dt><dt><span class="sect2"><a href="ecpg-informix-compat.html#ECPG-INFORMIX-STATEMENTS">36.15.2. Additional/Missing Embedded SQL Statements</a></span></dt><dt><span class="sect2"><a href="ecpg-informix-compat.html#ECPG-INFORMIX-SQLDA">36.15.3. Informix-compatible SQLDA Descriptor Areas</a></span></dt><dt><span class="sect2"><a href="ecpg-informix-compat.html#ECPG-INFORMIX-FUNCTIONS">36.15.4. Additional Functions</a></span></dt><dt><span class="sect2"><a href="ecpg-informix-compat.html#ECPG-INFORMIX-CONSTANTS">36.15.5. Additional Constants</a></span></dt></dl></dd><dt><span class="sect1"><a href="ecpg-oracle-compat.html">36.16. <span class="productname">Oracle</span> Compatibility Mode</a></span></dt><dt><span class="sect1"><a href="ecpg-develop.html">36.17. Internals</a></span></dt></dl></div><a id="id-1.7.5.2" class="indexterm"></a><a id="id-1.7.5.3" class="indexterm"></a><a id="id-1.7.5.4" class="indexterm"></a><p>
  This chapter describes the embedded <acronym class="acronym">SQL</acronym> package
  for <span class="productname">PostgreSQL</span>. It was written by
  Linus Tolke (<code class="email">&lt;<a class="email" href="mailto:linus@epact.se">linus@epact.se</a>&gt;</code>) and Michael Meskes
  (<code class="email">&lt;<a class="email" href="mailto:meskes@postgresql.org">meskes@postgresql.org</a>&gt;</code>). Originally it was written to work with
  <acronym class="acronym">C</acronym>. It also works with <acronym class="acronym">C++</acronym>, but
  it does not recognize all <acronym class="acronym">C++</acronym> constructs yet.
 </p><p>
  This documentation is quite incomplete.  But since this
  interface is standardized, additional information can be found in
  many resources about SQL.
 </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="lo-examplesect.html" title="35.5. Example Program">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="client-interfaces.html" title="Part IV. Client Interfaces">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-concept.html" title="36.1. The Concept">Next</a></td></tr><tr><td width="40%" align="left" valign="top">35.5. Example Program </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.6 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 36.1. The Concept</td></tr></table></div></body></html>