File: ecpg.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (98 lines) | stat: -rw-r--r-- 6,328 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter30.ECPG - Embedded SQL in C</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="client-interfaces.html" title="PartIV.Client Interfaces">
<link rel="prev" href="lo-examplesect.html" title="29.5.Example Program">
<link rel="next" href="ecpg-connect.html" title="30.2.Connecting to the Database Server">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en" id="ecpg">
<div class="titlepage"><div><div><h2 class="title">
<a name="ecpg"></a>Chapter30.<span class="application">ECPG</span> - Embedded <acronym class="acronym">SQL</acronym> in C</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="sect1"><a href="ecpg.html#ecpg-concept">30.1. The Concept</a></span></dt>
<dt><span class="sect1"><a href="ecpg-connect.html">30.2. Connecting to the Database Server</a></span></dt>
<dt><span class="sect1"><a href="ecpg-disconnect.html">30.3. Closing a Connection</a></span></dt>
<dt><span class="sect1"><a href="ecpg-commands.html">30.4. Running SQL Commands</a></span></dt>
<dt><span class="sect1"><a href="ecpg-set-connection.html">30.5. Choosing a Connection</a></span></dt>
<dt><span class="sect1"><a href="ecpg-variables.html">30.6. Using Host Variables</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="ecpg-variables.html#id689929">30.6.1. Overview</a></span></dt>
<dt><span class="sect2"><a href="ecpg-variables.html#id689971">30.6.2. Declare Sections</a></span></dt>
<dt><span class="sect2"><a href="ecpg-variables.html#id690062">30.6.3. <code class="command">SELECT INTO</code> and <code class="command">FETCH INTO</code></a></span></dt>
<dt><span class="sect2"><a href="ecpg-variables.html#id690170">30.6.4. Indicators</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="ecpg-dynamic.html">30.7. Dynamic SQL</a></span></dt>
<dt><span class="sect1"><a href="ecpg-descriptors.html">30.8. Using SQL Descriptor Areas</a></span></dt>
<dt><span class="sect1"><a href="ecpg-errors.html">30.9. Error Handling</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="ecpg-errors.html#id690723">30.9.1. Setting Callbacks</a></span></dt>
<dt><span class="sect2"><a href="ecpg-errors.html#id691022">30.9.2. sqlca</a></span></dt>
<dt><span class="sect2"><a href="ecpg-errors.html#id691292">30.9.3. <code class="literal">SQLSTATE</code> vs <code class="literal">SQLCODE</code></a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="ecpg-include.html">30.10. Including Files</a></span></dt>
<dt><span class="sect1"><a href="ecpg-process.html">30.11. Processing Embedded SQL Programs</a></span></dt>
<dt><span class="sect1"><a href="ecpg-library.html">30.12. Library Functions</a></span></dt>
<dt><span class="sect1"><a href="ecpg-develop.html">30.13. Internals</a></span></dt>
</dl>
</div>
<a name="id689212"></a><a name="id689026"></a><a name="id689036"></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 href="mailto:linus@epact.se">linus@epact.se</a>&gt;</code>) and Michael Meskes
  (<code class="email">&lt;<a 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 class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="ecpg-concept"></a>30.1.The Concept</h2></div></div></div>
<p>   An embedded SQL program consists of code written in an ordinary
   programming language, in this case C, mixed with SQL commands in
   specially marked sections.  To build the program, the source code
   is first passed through the embedded SQL preprocessor, which converts it
   to an ordinary C program, and afterwards it can be processed by a C
   compiler.
  </p>
<p>   Embedded <acronym class="acronym">SQL</acronym> has advantages over other methods
   for handling <acronym class="acronym">SQL</acronym> commands from C code. First, it
   takes care of the tedious passing of information to and from
   variables in your <acronym class="acronym">C</acronym> program.  Second, the SQL
   code in the program is checked at build time for syntactical
   correctness.  Third, embedded <acronym class="acronym">SQL</acronym> in C is
   specified in the <acronym class="acronym">SQL</acronym> standard and supported by
   many other <acronym class="acronym">SQL</acronym> database systems.  The
   <span class="productname">PostgreSQL</span> implementation is designed to match this
   standard as much as possible, and it is usually possible to port
   embedded <acronym class="acronym">SQL</acronym> programs written for other SQL
   databases to <span class="productname">PostgreSQL</span> with relative
   ease.
  </p>
<p>   As already stated, programs written for the embedded
   <acronym class="acronym">SQL</acronym> interface are normal C programs with special
   code inserted to perform database-related actions.  This special
   code always has the form
</p>
<pre class="programlisting">EXEC SQL ...;</pre>
<p>
   These statements syntactically take the place of a C statement.
   Depending on the particular statement, they may appear at the
   global level or within a function.  Embedded
   <acronym class="acronym">SQL</acronym> statements follow the case-sensitivity rules
   of normal <acronym class="acronym">SQL</acronym> code, and not those of C.
  </p>
<p>   The following sections explain all the embedded SQL statements.
  </p>
</div>
</div></body>
</html>