diff options
author | Marc G. Fournier <scrappy@hub.org> | 2002-08-22 00:15:14 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 2002-08-22 00:15:14 +0000 |
commit | da4683fbe1cba48cf5b5b29055b66e0bacb00162 (patch) | |
tree | 87834b1b18614313e895dcc8c504f58af9f6b4b2 /src/interfaces/libpq++/examples/testlibpq3.cc | |
parent | b663f3443ba096a06970214c3e83e79f6e570b84 (diff) |
Okay, libpq++ is moved to GBorg, and all traces of it have been removed
from the core repository ... I haven't *moved* the libpq++ files out of the
tree, mainly as we want to keep them in place for past branches ...
Peter, I think I've covered all the files I need, and re-ran autoconf to make
sure the configure file is in place properly ...
Diffstat (limited to 'src/interfaces/libpq++/examples/testlibpq3.cc')
-rw-r--r-- | src/interfaces/libpq++/examples/testlibpq3.cc | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/interfaces/libpq++/examples/testlibpq3.cc b/src/interfaces/libpq++/examples/testlibpq3.cc deleted file mode 100644 index fa2625f5b28..00000000000 --- a/src/interfaces/libpq++/examples/testlibpq3.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* -* testlibpq3.cc -* Test the C++ version of LIBPQ, the POSTGRES frontend library. -* -* queries the template1 database for a list of database names using transaction block -* and cursor interface. -* -*/ - -#include <iostream.h> -#include <iomanip.h> -#include "libpq++.h" - -int main() -{ - // Begin, by establishing a connection to the backend. - // When no parameters are given then the system will - // try to use reasonable defaults by looking up environment variables - // or, failing that, using hardwired constants. - // Create a cursor database query object. - // All queries using cursor will be performed through this object. - const char* dbName = "dbname=template1"; - PgCursor cData(dbName, "myportal"); - - // check to see that the backend connection was successfully made - if ( cData.ConnectionBad() ) - { - cerr << "Connection to database '" << dbName << "' failed." << endl - << "Error returned: " << cData.ErrorMessage() << endl; - exit(1); - } - - // submit command to the backend - if ( !cData.Declare("select * from pg_database") ) - { - cerr << "DECLARE CURSOR command failed" << endl; - exit(1); - } - - // fetch instances from the pg_cDatabase, the system catalog of cDatabases - if ( !cData.Fetch() ) - { - cerr << "FETCH ALL command didn't return tuples properly" << endl; - exit(1); - } - - // first, print out the attribute names - int nFields = cData.Fields(); - for (int i = 0; i < nFields; i++) - cout << setiosflags(ios::right) << setw(15) << cData.FieldName(i); - cout << endl << endl; - - // next, print out the instances - for (int i = 0; i < cData.Tuples(); i++) - { - for (int j = 0; j < nFields; j++) - cout << setiosflags(ios::right) << setw(15) << cData.GetValue(i, j); - cout << endl; - } - return 0; -} |