~ubuntu-branches/ubuntu/lucid/libpqxx3/lucid

« back to all changes in this revision

Viewing changes to doc/html/Tutorial/ch02.html

  • Committer: Bazaar Package Importer
  • Author(s): Eugene V. Lyubimkin
  • Date: 2009-09-28 01:13:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090928011316-sqyruofmj5j1y7kz
Tags: 3.0.2-1
* New upstream bugfix-only release.
* debian/control:
  - Bumped Standards-Version to 3.8.3, no changes needed.
  - Added {misc:Depends} to dependencies of binary packages.
  - Updated my mail address.
* debian/libpqxx3-doc.install:
  - Added test headers to allow compiling examples. (Closes: 539814)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
 
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
 
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter&#160;2.&#160;Class overview</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><link rel="start" href="index.html" title="libpqxx tutorial" /><link rel="up" href="index.html" title="libpqxx tutorial" /><link rel="prev" href="ch01.html" title="Chapter&#160;1.&#160;Why another C++ SQL library?" /><link rel="next" href="ch03.html" title="Chapter&#160;3.&#160;Tutorial" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;2.&#160;Class overview</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch03.html">Next</a></td></tr></table><hr /></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="classoverview"></a>Chapter&#160;2.&#160;Class overview</h2></div></div></div><p>
4
 
      To work with <span class="productname">libpqxx</span>&#8482;, you need to be aware of
 
3
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 2. Class overview</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><link rel="start" href="index.html" title="libpqxx tutorial" /><link rel="up" href="index.html" title="libpqxx tutorial" /><link rel="prev" href="ch01.html" title="Chapter 1. Why another C++ SQL library?" /><link rel="next" href="ch03.html" title="Chapter 3. Tutorial" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 2. Class overview</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch03.html">Next</a></td></tr></table><hr /></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="classoverview"></a>Chapter 2. Class overview</h2></div></div></div><p>
 
4
      To work with <span class="productname">libpqxx</span>™, you need to be aware of
5
5
      at least the following classes.  These are all introduced in a dedicated
6
6
      namespace, <code class="literal">pqxx</code>:
7
7
    </p><div class="itemizedlist"><ul type="disc"><li><p>
8
8
          <code class="literal">connection</code> represents a connection from your
9
 
          program to a <span class="productname">PostgreSQL</span>&#8482; back-end server.
 
9
          program to a <span class="productname">PostgreSQL</span>™ back-end server.
10
10
          Naturally your program may open multiple connections, simultaneous or
11
11
          not, to any number of databases.
12
12
        </p></li><li><p>
18
18
          everything done within that <code class="literal">transaction</code> is undone
19
19
          by the backend as if it had never happened.
20
20
 
21
 
          <sup>[<a id="id2493683" href="#ftn.id2493683" class="footnote">2</a>]</sup>
 
21
          <sup>[<a id="id2649801" href="#ftn.id2649801" class="footnote">2</a>]</sup>
22
22
 
23
23
          You may execute any number of transactions consecutively on a single
24
24
          <code class="literal">connection</code>, but only one at a time.
41
41
    </p><p>
42
42
      There are other classes that may be of interest to you; these are either
43
43
      not essential to writing a simple program using
44
 
      <span class="productname">libpqxx</span>&#8482;, or are used in such a way that
 
44
      <span class="productname">libpqxx</span>™, or are used in such a way that
45
45
      knowledge of them is not immediately necessary.  You will probably want to
46
46
      look them up at some point when it becomes necessary to understand complex
47
47
      compiler warnings.  Unfortunately C++ compilers are not yet very good at
51
51
      Some of the classes you may become interested in fairly quickly are:
52
52
    </p><div class="itemizedlist"><ul type="disc"><li><p>
53
53
          <code class="literal">broken_connection</code> is an exception class that is
54
 
          thrown if <span class="productname">libpqxx</span>&#8482; loses its connection to
 
54
          thrown if <span class="productname">libpqxx</span>™ loses its connection to
55
55
          the back-end.  It is derived from the standard C++ exception
56
56
          <code class="literal">std::runtime_error</code>, and can generally be treated as
57
57
          such.
140
140
          access to a table for either reading (through its child class
141
141
          <code class="literal">tablereader</code>) or writing (through child class
142
142
          <code class="literal">tablewriter</code>) using
143
 
          <span class="productname">PostgreSQL</span>&#8482;'s <code class="literal">COPY</code>
 
143
          <span class="productname">PostgreSQL</span>™'s <code class="literal">COPY</code>
144
144
          command.  This is typically much faster than issuing
145
145
          <code class="literal">SELECT</code> or <code class="literal">UPDATE</code> queries.
146
146
        </p></li><li><p>
174
174
        </p></li><li><p>
175
175
          <code class="literal">notify_listener</code> is an instance of the Observer
176
176
          design pattern.  Any code connected to a backend may flag an event
177
 
          using the <span class="productname">PostgreSQL</span>&#8482;
 
177
          using the <span class="productname">PostgreSQL</span>™
178
178
          <code class="literal">NOTIFY</code> command.  Frontends connected to that same
179
179
          backend database may be listening for an event of that name to occur.
180
 
          A frontend using <span class="productname">libpqxx</span>&#8482; does this by
 
180
          A frontend using <span class="productname">libpqxx</span>™ does this by
181
181
          registering an observer object derived from
182
182
          <code class="literal">notify_listener</code>, which will be invoked by
183
 
          <span class="productname">libpqxx</span>&#8482; to handle the event when it occurs.
 
183
          <span class="productname">libpqxx</span>™ to handle the event when it occurs.
184
184
        </p><p>
185
185
          Something every programmer using notification listeners in PostgreSQL
186
186
          should know, by the way, is that notifications are not delivered to
234
234
          <code class="function">to_string</code>.  It is used by eg.
235
235
          <code class="function">result::field::to()</code> to convert the incoming
236
236
          field data (which is in text format) to the desired C++ type.
237
 
        </p></li></ul></div><div class="footnotes"><br /><hr width="100" align="left" /><div class="footnote"><p><sup>[<a id="ftn.id2493683" href="#id2493683" class="para">2</a>] </sup>
238
 
              Actually <span class="productname">libpqxx</span>&#8482; provides three classes
 
237
        </p></li></ul></div><div class="footnotes"><br /><hr width="100" align="left" /><div class="footnote"><p><sup>[<a id="ftn.id2649801" href="#id2649801" class="para">2</a>] </sup>
 
238
              Actually <span class="productname">libpqxx</span>™ provides three classes
239
239
              doing this at various levels of reliability, called
240
240
              <code class="literal">nontransaction</code>, <code class="literal">transaction</code>,
241
241
              and <code class="literal">robusttransaction</code> for no, standard, and
242
242
              best reliability respectively.
243
 
            </p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="ch03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;1.&#160;Why another C++ SQL library?&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Chapter&#160;3.&#160;Tutorial</td></tr></table></div></body></html>
 
243
            </p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 1. Why another C++ SQL library? </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 3. Tutorial</td></tr></table></div></body></html>