summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq++/examples/testlibpq0.cc
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1997-02-13 10:01:05 +0000
committerMarc G. Fournier <scrappy@hub.org>1997-02-13 10:01:05 +0000
commiteacd0fd938663b8c673d8e3ac9549c9f3b7b463d (patch)
tree6c4f11621fc2fd649d2864a7b9a907cbcbf97df7 /src/interfaces/libpq++/examples/testlibpq0.cc
parentd62267c70706b7d60895401aae1346cf6cd7cead (diff)
downloadpostgresql-eacd0fd938663b8c673d8e3ac9549c9f3b7b463d.tar.gz
Bring in Leo's <lsh@lubrizol.com> massive changes to libpq++
Diffstat (limited to 'src/interfaces/libpq++/examples/testlibpq0.cc')
-rw-r--r--src/interfaces/libpq++/examples/testlibpq0.cc57
1 files changed, 30 insertions, 27 deletions
diff --git a/src/interfaces/libpq++/examples/testlibpq0.cc b/src/interfaces/libpq++/examples/testlibpq0.cc
index e8adb21f1b..43f8e93d15 100644
--- a/src/interfaces/libpq++/examples/testlibpq0.cc
+++ b/src/interfaces/libpq++/examples/testlibpq0.cc
@@ -9,41 +9,44 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/testlibpq0.cc,v 1.2 1996/11/18 01:44:23 bryanh Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/testlibpq0.cc,v 1.3 1997/02/13 10:00:42 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
-#include <stdio.h>
-#include "libpq++.H"
+#include <iostream.h>
+#include <libpq++.h>
-int
-main()
+int main()
{
+ // Open the connection to the database and make sure it's OK
+ PgDatabase data("template1");
+ if ( data.ConnectionBad() ) {
+ cout << "Connection was unsuccessful..." << endl
+ << "Error message returned: " << data.ErrorMessage() << endl;
+ return 1;
+ }
+ else
+ cout << "Connection successful... Enter queries below:" << endl;
+
+ // Interactively obtain and execute queries
ExecStatusType status;
- PGenv env;
- PGdatabase* data;
-
- char buf[10000];
+ string buf;
int done = 0;
-
- data = new PGdatabase(&env, "template1");
-
- if (data->status() == CONNECTION_BAD)
- printf("connection was unsuccessful\n%s\n", data->errormessage());
- else
- printf("connection successful\n");
-
while (!done)
{
- printf("> ");fflush(stdout);
- if (gets(buf) && buf[0]!='\0')
- if((status = data->exec(buf)) == PGRES_TUPLES_OK)
- data->printtuples(stdout, 1, "|", 1, 0);
- else
- printf("status = %d\nerrorMessage = %s\n", status,
- data->errormessage());
+ cout << "> ";
+ cout.flush();
+ getline(cin, buf);
+ if ( buf != "" )
+ if ( (status = data.Exec( buf.c_str() )) == PGRES_TUPLES_OK )
+ data.DisplayTuples();
+ else
+ cout << "No tuples returned..." << endl
+ << "status = " << status << endl
+ << "Error returned: " << data.ErrorMessage() << endl;
else
- done = 1;
- }
-}
+ done = 1;
+ }
+ return 0;
+} // End main()