1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

From: Michael Meskes <meskes@topsystem.de>

Here's my next patch. this one should fix some more bugs. ecpg now fully
understands the whenever statement.
This commit is contained in:
Marc G. Fournier
1998-02-19 13:52:17 +00:00
parent ed875a4132
commit 1d6424b1fb
11 changed files with 243 additions and 52 deletions

View File

@ -2,10 +2,11 @@
exec sql include sqlca;
#define SQLCODE sqlca.sqlcode
extern void ECPGdebug(int n, FILE *dbgs);
exec sql whenever not found sqlprint;
exec sql whenever sqlerror db_error(msg);
void
db_error (char *msg)
{
@ -24,37 +25,32 @@ exec sql begin declare section;
} birth;
} personal;
exec sql end declare section;
char msg[128];
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
strcpy(msg, "connect");
exec sql connect 'mm';
if (SQLCODE)
db_error ("connect");
strcpy(msg, "declare");
exec sql declare cur cursor for
select name, born, age from meskes;
if (SQLCODE) db_error ("declare");
exec sql open cur;
if (SQLCODE)
db_error ("open");
while (1) {
strcpy(msg, "fetch");
exec sql fetch in cur into :personal;
if (SQLCODE)
break;
printf ("%8.8s was born %d (age = %d)\n", personal.name.arr, personal.birth.born, personal.birth.age);
}
if (SQLCODE < 0)
db_error ("fetch");
strcpy(msg, "close");
exec sql close cur;
if (SQLCODE) db_error ("close");
strcpy(msg, "commit");
exec sql commit;
if (SQLCODE) db_error ("commit");
if (dbgs != NULL)
fclose(dbgs);