1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

From: Michael Meskes <meskes@topsystem.de>

Cleanups for ecpg, as well as a missing patch so that its configured in
This commit is contained in:
Marc G. Fournier
1998-02-11 15:30:00 +00:00
parent 72aa1dabb9
commit df10360d8e
7 changed files with 151 additions and 97 deletions

View File

@ -1,14 +1,14 @@
all: test2 perftest
test2: test2.c
gcc -g -I ../include -I ../../../libpq -o test2 test2.c ../lib/libecpg.a ../../../libpq/libpq.a -lcrypt
gcc -g -I ../include -I ../../libpq -o test2 test2.c -L../lib -lecpg -L../../libpq -lpq -lcrypt
test2.c: test2.pgc
../preproc/ecpg test2.pgc
ecpg test2.pgc
perftest: perftest.c
gcc -g -I ../include -I ../../../libpq -o perftest perftest.c ../lib/libecpg.a ../../../libpq/libpq.a -lcrypt
gcc -g -I ../include -I ../../libpq -o perftest perftest.c -L../lib -lecpg -L../../libpq -lpq -lcrypt
perftest.c: perftest.pgc
../preproc/ecpg perftest.pgc
ecpg perftest.pgc
clean:
/bin/rm test2 test2.c perftest perftest.c
/bin/rm test2 test2.c perftest perftest.c log

View File

@ -1,7 +1,11 @@
#include <stdio.h>
exec sql include sqlca;
#define SQLCODE sqlca.sqlcode
extern void ECPGdebug(int n, FILE *dbgs);
void
db_error (char *msg)
{
@ -14,17 +18,20 @@ int
main ()
{
exec sql begin declare section;
varchar text[8];
int count;
double control;
varchar name[8];
long born;
exec sql end declare section;
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
exec sql connect 'mm';
if (SQLCODE)
db_error ("connect");
exec sql declare cur cursor for
select text, control, count from test;
select name, born from meskes;
if (SQLCODE) db_error ("declare");
exec sql open cur;
@ -32,10 +39,10 @@ exec sql end declare section;
db_error ("open");
while (1) {
exec sql fetch in cur into :text, :control, :count;
exec sql fetch in cur into :name, :born;
if (SQLCODE)
break;
printf ("%8.8s %d %f\n", text.arr, count, control);
printf ("%8.8s was born %d\n", name.arr, born);
}
if (SQLCODE < 0)
@ -46,5 +53,8 @@ exec sql end declare section;
exec sql commit;
if (SQLCODE) db_error ("commit");
if (dbgs != NULL)
fclose(dbgs);
return (0);
}