summaryrefslogtreecommitdiff
path: root/tests/psql
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2008-07-13 12:34:06 +0200
committerAndreas Baumann <abaumann@yahoo.com>2008-07-13 12:34:06 +0200
commitc5613aeacd0ad523c49a19848def02f2e8118df7 (patch)
treef6068a6c344b537c5df0c8b99be7d90844c2e6f0 /tests/psql
parent59cda05cd517f3191abab0b551733d72105e6450 (diff)
downloadcrawler-c5613aeacd0ad523c49a19848def02f2e8118df7.tar.gz
crawler-c5613aeacd0ad523c49a19848def02f2e8118df7.tar.bz2
made an example with templated prepared statements (libpqxx, brilliant!)
Diffstat (limited to 'tests/psql')
-rw-r--r--tests/psql/test2.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/tests/psql/test2.cpp b/tests/psql/test2.cpp
index 5d4e06f..852f257 100644
--- a/tests/psql/test2.cpp
+++ b/tests/psql/test2.cpp
@@ -13,19 +13,15 @@ int main( ) {
//c.trace( stdout );
- cout << "Conntected to database." << endl
- << "Backend protocol version: " << c.server_version( ) << endl
- << "Protocol version: " << c.protocol_version( ) << endl
- << "Server PID: " << c.backendpid( ) << endl
- << "Prepared Statements: " << c.supports( c.cap_prepared_statements ) << endl;
-
work t( c, "test transaction" );
t.exec( "create table test( a integer, b integer)" );
for( unsigned int i = 0; i < 1000; i++ ) {
- ostringstream sql;
- sql << "insert into test values( '" << i << "', '" << i << "' )";
- t.exec( sql.str( ) );
+ c.prepare( "insertTestStmt",
+ "insert into test(a,b) values($1,$2)" )
+ ( "integer", prepare::treat_direct )
+ ( "integer", prepare::treat_direct );
+ t.prepared( "insertTestStmt" )(i)(i).exec( );
}
result r( t.exec( "select * from test" ) );