11 connection
C("dbname=test");
12 cout
<< "Connected to " << C
.dbname() << endl
;
16 R
= W
.exec("DROP TABLE employee");
17 R
= W
.exec("CREATE TABLE employee (id SERIAL PRIMARY KEY, name TEXT, salary INT)");
19 C
.prepare("ins","INSERT INTO employee (name,salary) VALUES($1,$2)")
20 ("varchar",prepare::treat_string
)
21 ("varchar",prepare::treat_direct
);
22 prepare::invocation
* call
= &W
.prepared("ins");
23 call
->operator()("john")(2).exec();
25 R = W.prepared("ins")("jack")(3).exec();
26 R = W.prepared("ins")("bob")(4).exec();
27 R = W.exec("SELECT name FROM employee");
29 cout << "Found " << R.size() << " employees:" << endl;
30 for (result::const_iterator r = R.begin();
34 cout << r[0].c_str() << endl;
37 cout << "Doubling all employees' salaries..." << endl;
38 W.exec("UPDATE employee SET salary=salary*2");
40 cout << "Making changes definite: ";
43 cout
<< "ok." << endl
;
45 catch (const exception
&e
)
47 cerr
<< e
.what() << endl
;