blob: e8adb21f1bef981dd54db7bc1341f1f075a20366 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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.2 1996/11/18 01:44:23 bryanh Exp $
*
*-------------------------------------------------------------------------
*/
#include <stdio.h>
#include "libpq++.H"
int
main()
{
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 = %d\nerrorMessage = %s\n", status,
data->errormessage());
else
done = 1;
}
}
|