[go: up one dir, main page]

File: index.html

package info (click to toggle)
soci 2.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,400 kB
  • ctags: 1,969
  • sloc: cpp: 17,658; sh: 8,749; makefile: 379
file content (94 lines) | stat: -rw-r--r-- 2,730 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type" />
  <link rel="stylesheet" type="text/css" href="style.css" />
  <title>SOCI</title>
</head>

<body>
<p class="banner">SOCI - The C++ Database Access Library</p>

<h1>Documentation and tutorial</h1>

<div class="navigation">
<a href="structure.html">Library structure, files and compilation</a><br />
<a href="errors.html">Errors</a><br />
<a href="basics.html">Connections and simple queries</a><br />
<a href="exchange.html">Exchanging data</a><br />
<a href="statements.html">Statements, procedures and transactions</a><br />
<a href="beyond.html">Beyond SOCI</a><br />
<a href="reference.html">Client interface reference</a><br />
<a href="backends.html">Backends reference</a><br />
<a href="rationale.html">Rationale FAQ</a><br /><br />
<a href="backends/index.html">Existing backends and supported platforms</a>
</div>

<p>The following (complete!) example is purposedly provided without any explanation.</p>

<pre class="example">
#include "soci.h"
#include "soci-oracle.h"
#include &lt;iostream&gt;
#include &lt;istream&gt;
#include &lt;ostream&gt;
#include &lt;string&gt;
#include &lt;exception&gt;

using namespace SOCI;
using namespace std;

bool getName(string &amp;name)
{
    cout &lt;&lt; "Enter name: ";
    return cin &gt;&gt; name;
}

int main()
{
    try
    {
        Session sql(oracle, "service=mydb user=john password=secret");

        int count;
        sql &lt;&lt; "select count(*) from phonebook", into(count);

        cout &lt;&lt; "We have " &lt;&lt; count &lt;&lt; " entries in the phonebook.\n";

        string name;
        while (getName(name))
        {
            string phone;
            eIndicator ind;
            sql &lt;&lt; "select phone from phonebook where name = :name",
                into(phone, ind), use(name);

            if (ind == eOK)
            {
                cout &lt;&lt; "The phone number is " &lt;&lt; phone &lt;&lt; '\n';
            }
            else
            {
                cout &lt;&lt; "There is no phone for " &lt;&lt; name &lt;&lt; '\n';
            }
        }
    }
    catch (exception const &amp;e)
    {
        cerr &lt;&lt; "Error: " &lt;&lt; e.what() &lt;&lt; '\n';
    }
}
</pre>

<table class="foot-links" border="0" cellpadding="2" cellspacing="2">
  <tr>
    <td class="foot-link-left"></td>
    <td class="foot-link-right">
      <a href="structure.html">Next (Library structure, files and compilation)</a>
    </td>
  </tr>
</table>

<p class="copyright">Copyright &copy; 2004-2006 Maciej Sobczak, Stephen Hutton</p>
</body>
</html>