diff options
| author | Marc G. Fournier <scrappy@hub.org> | 1999-02-28 07:25:34 +0000 |
|---|---|---|
| committer | Marc G. Fournier <scrappy@hub.org> | 1999-02-28 07:25:34 +0000 |
| commit | d077c6149269701d0831634e8800b53c528d13ac (patch) | |
| tree | ffca34f22c5fec39ebcd11c671003e9b11a4f103 /src/interfaces/ecpg/test | |
| parent | 51f0f6ddc8359d088a6d4892eec0ce90b485b501 (diff) | |
| download | postgresql-d077c6149269701d0831634e8800b53c528d13ac.tar.gz | |
From: Michael Meskes <Michael_Meskes@topmail.de>
+
+ Tue Feb 23 17:32:25 CET 1999
+
+ - Other than a struct a union itself cannot be specified as variable.
+
+ Fri Feb 26 07:18:25 CET 1999
+
+ - Synced preproc.y with gram.y.
+
+ Sat Feb 27 20:30:03 CET 1999
+
+ - Added automatic allocating for NULL pointers.
Diffstat (limited to 'src/interfaces/ecpg/test')
| -rw-r--r-- | src/interfaces/ecpg/test/test2.pgc | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/interfaces/ecpg/test/test2.pgc b/src/interfaces/ecpg/test/test2.pgc index 568add1463..f50a9d5100 100644 --- a/src/interfaces/ecpg/test/test2.pgc +++ b/src/interfaces/ecpg/test/test2.pgc @@ -5,8 +5,8 @@ exec sql include header_test; exec sql type c is char reference; typedef char* c; -exec sql type ind is union { int integer; short smallinteger; }; -typedef union { int integer; short smallinteger; } ind; +exec sql type ind is union { int integer; short smallint; }; +typedef union { int integer; short smallint; } ind; int main () @@ -23,7 +23,7 @@ exec sql begin declare section; int ind_married; ind children; ind ind_children; - char married[9]; + char *married = NULL; c testname="Petra"; char *query="select name, born, age, married, children from meskes where name = :var1"; exec sql end declare section; @@ -43,7 +43,7 @@ exec sql end declare section; exec sql connect to unix:postgresql://localhost:5432/mm; strcpy(msg, "create"); - exec sql create table meskes(name char(8), born integer, age smallint, married char(8), children integer); + exec sql create table meskes(name char(8), born integer, age smallint, married date, children integer); strcpy(msg, "insert"); exec sql insert into meskes(name, married, children) values ('Petra', '19900404', 3); @@ -62,17 +62,20 @@ exec sql end declare section; while (1) { strcpy(msg, "fetch"); - exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallinteger; + exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint; printf("%8.8s", personal.name.arr); - if (!ind_personal.ind_birth.born) + if (ind_personal.ind_birth.born >= 0) printf(", born %d", personal.birth.born); - if (!ind_personal.ind_birth.age) + if (ind_personal.ind_birth.age >= 0) printf(", age = %d", personal.birth.age); - if (!ind_married) - printf(", married %s", married); - if (!ind_children.smallinteger) + if (ind_married >= 0) + printf(", married %10.10s", married); + if (ind_children.smallint >= 0) printf(", children = %d", children.integer); putchar('\n'); + + free(married); + married = NULL; } strcpy(msg, "close"); @@ -89,19 +92,21 @@ exec sql end declare section; while (1) { strcpy(msg, "fetch"); - exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallinteger; + exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint; printf("%8.8s", personal.name.arr); - if (!ind_personal.ind_birth.born) + if (ind_personal.ind_birth.born >= 0) printf(", born %d", personal.birth.born); - if (!ind_personal.ind_birth.age) + if (ind_personal.ind_birth.age >= 0) printf(", age = %d", personal.birth.age); - if (!ind_married) - printf(", married %s", married); - if (!ind_children.smallinteger) + if (ind_married >= 0) + printf(", married %10.10s", married); + if (ind_children.smallint >= 0) printf(", children = %d", children.integer); putchar('\n'); } + free(married); + strcpy(msg, "close"); exec sql close prep; |
