mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Postgres95 1.01 Distribution - Virgin Sources
This commit is contained in:
49
src/interfaces/libpq++/examples/testlibpq0.cc
Normal file
49
src/interfaces/libpq++/examples/testlibpq0.cc
Normal file
@@ -0,0 +1,49 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* testlibpq0.c--
|
||||
* small test program for libpq++,
|
||||
* small interactive loop where queries can be entered interactively
|
||||
* and sent to the backend
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/testlibpq0.cc,v 1.1.1.1 1996/07/09 06:22:18 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "libpq++.H"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
ExecStatusType status;
|
||||
PGenv env;
|
||||
PGdatabase* data;
|
||||
|
||||
char buf[10000];
|
||||
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 = %s\nerrorMessage = %s\n", status,
|
||||
data->errormessage());
|
||||
else
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user