/* End of automatic include section */
#line 1 "define.pgc"
-#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
#line 1 "regression.h"
-#line 4 "define.pgc"
-
-
-typedef long mmInteger ;
-
#line 6 "define.pgc"
-#line 6 "define.pgc"
-typedef char mmChar ;
+/* exec sql whenever sqlerror sqlprint ; */
+#line 8 "define.pgc"
-#line 7 "define.pgc"
-#line 7 "define.pgc"
-typedef short mmSmallInt ;
-#line 8 "define.pgc"
-#line 8 "define.pgc"
+/* exec sql type intarray is int [ 6 ] */
+#line 13 "define.pgc"
+typedef int intarray[ 6];
+int
+main(void)
+{
/* exec sql begin declare section */
-
-
-
-
+ typedef char string [ 8 ] ;
-struct TBempl {
-#line 13 "define.pgc"
- mmInteger idnum ;
+#line 21 "define.pgc"
+
+
+
+
-#line 14 "define.pgc"
- mmChar name [ 21 ] ;
+#line 22 "define.pgc"
+ intarray amount ;
-#line 15 "define.pgc"
- mmSmallInt accs ;
- } ;/* exec sql end declare section */
-#line 17 "define.pgc"
-
-
-int
-main (void)
-{
- /* exec sql begin declare section */
-
-
#line 23 "define.pgc"
- struct TBempl empl ;
-/* exec sql end declare section */
+ char name [ 6 ] [ 8 ] ;
+
#line 24 "define.pgc"
+ char letter [ 6 ] [ 1 ] ;
+
+#if 0
+
+#line 26 "define.pgc"
+ int not_used ;
+
+#endif
+/* exec sql end declare section */
+#line 29 "define.pgc"
+ int i,j;
- ECPGdebug (1, stderr);
+ ECPGdebug(1, stderr);
- empl.idnum = 1;
- { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
-#line 29 "define.pgc"
+ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
+#line 34 "define.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 34 "define.pgc"
- if (sqlca.sqlcode)
- {
- printf ("connect error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
- { ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint ) ", ECPGt_EOIT, ECPGt_EORT);}
+ { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 36 "define.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 36 "define.pgc"
+
+ { ECPGtrans(__LINE__, NULL, "commit");
#line 37 "define.pgc"
- if (sqlca.sqlcode)
- {
- printf ("create error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
-
- { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'first user' , 320 ) ", ECPGt_EOIT, ECPGt_EORT);}
-#line 44 "define.pgc"
-
- if (sqlca.sqlcode)
- {
- printf ("insert error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
-
- { ECPGdo(__LINE__, 0, 1, NULL, "select idnum , name , accs from empl where idnum = ? ",
- ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 37 "define.pgc"
+
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 39 "define.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 39 "define.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 40 "define.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 40 "define.pgc"
+
+ { ECPGtrans(__LINE__, NULL, "commit");
+#line 41 "define.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 41 "define.pgc"
+
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT,
+ ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,&(empl.name),(long)21,(long)1,(21)*sizeof(char),
+ ECPGt_int,(amount),(long)1,(long)6,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 54 "define.pgc"
+ ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 43 "define.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 43 "define.pgc"
+
+
+ for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
+ {
+ /* exec sql begin declare section */
+
+
+
+#line 48 "define.pgc"
+ char n [ 8 ] , l = letter [ i ] [ 0 ] ;
+
+#line 49 "define.pgc"
+ int a = amount [ i ] ;
+/* exec sql end declare section */
+#line 50 "define.pgc"
+
+
+ strncpy(n, name[i], 8);
+ printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
+ }
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+#line 56 "define.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 56 "define.pgc"
+
+ { ECPGtrans(__LINE__, NULL, "commit");
+#line 57 "define.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 57 "define.pgc"
+
+ { ECPGdisconnect(__LINE__, "CURRENT");
+#line 58 "define.pgc"
- if (sqlca.sqlcode)
- {
- printf ("select error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
- printf ("id=%ld name=%s, accs=%d\n", empl.idnum, empl.name, empl.accs);
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 58 "define.pgc"
- { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 62 "define.pgc"
- exit (0);
+ return (0);
}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 36: QUERY: create table empl ( idnum integer , name char ( 20 ) , accs smallint ) on connection regress1
+[NO_PID]: ECPGexecute line 36: QUERY: create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 36 Ok: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 44: QUERY: insert into empl values ( 1 , 'first user' , 320 ) on connection regress1
+[NO_PID]: ECPGtrans line 37 action = commit connection = regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 44 Ok: INSERT 0 1
+[NO_PID]: ECPGexecute line 39: QUERY: insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 51: QUERY: select idnum , name , accs from empl where idnum = 1 on connection regress1
+[NO_PID]: ECPGexecute line 39 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 51: Correctly got 1 tuples with 3 fields
+[NO_PID]: ECPGexecute line 40: QUERY: insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 51: RESULT: 1 offset: -1 array: Yes
+[NO_PID]: ECPGexecute line 40 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 51: RESULT: first user offset: -1 array: Yes
+[NO_PID]: ECPGtrans line 41 action = commit connection = regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 51: RESULT: 320 offset: -1 array: Yes
+[NO_PID]: ECPGexecute line 43: QUERY: select * from test on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 43: Correctly got 2 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 43: RESULT: false offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 43: RESULT: true offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 43: RESULT: 1 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 43: RESULT: 2 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 43: RESULT: f offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 43: RESULT: t offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 56: QUERY: drop table test on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 56 Ok: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans line 57 action = commit connection = regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection regress1 closed.
[NO_PID]: sqlca: code: 0, state: 00000
-id=1 name=first user , accs=320
+name[0]=false amount[0]=1 letter[0]=f
+name[1]=true amount[1]=2 letter[1]=t
--- /dev/null
+/* Processed by ecpg (4.2.1) */
+/* These include files are added by the preprocessor */
+#include <ecpgtype.h>
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+
+#line 1 "type.pgc"
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 4 "type.pgc"
+
+
+typedef long mmInteger ;
+
+#line 6 "type.pgc"
+
+#line 6 "type.pgc"
+
+typedef char mmChar ;
+
+#line 7 "type.pgc"
+
+#line 7 "type.pgc"
+
+typedef short mmSmallInt ;
+
+#line 8 "type.pgc"
+
+#line 8 "type.pgc"
+
+
+/* exec sql type string is char [ 11 ] */
+#line 10 "type.pgc"
+
+typedef char string[11];
+
+/* exec sql type c is char reference */
+#line 13 "type.pgc"
+
+typedef char* c;
+
+/* exec sql begin declare section */
+
+
+
+
+
+
+struct TBempl {
+#line 19 "type.pgc"
+ mmInteger idnum ;
+
+#line 20 "type.pgc"
+ mmChar name [ 21 ] ;
+
+#line 21 "type.pgc"
+ mmSmallInt accs ;
+ } ;/* exec sql end declare section */
+#line 23 "type.pgc"
+
+
+int
+main (void)
+{
+ /* exec sql begin declare section */
+
+
+
+
+
+
+
+
+
+#line 29 "type.pgc"
+ struct TBempl empl ;
+
+#line 30 "type.pgc"
+ string str ;
+
+#line 31 "type.pgc"
+ c ptr = NULL ;
+
+#line 36 "type.pgc"
+ struct varchar_vc {
+#line 34 "type.pgc"
+ int len ;
+
+#line 35 "type.pgc"
+ char text [ 10 ] ;
+ } vc ;
+/* exec sql end declare section */
+#line 37 "type.pgc"
+
+
+ /* exec sql var vc is [ 10 ] */
+#line 39 "type.pgc"
+
+ ECPGdebug (1, stderr);
+
+ empl.idnum = 1;
+ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+#line 43 "type.pgc"
+
+ if (sqlca.sqlcode)
+ {
+ printf ("connect error = %ld\n", sqlca.sqlcode);
+ exit (sqlca.sqlcode);
+ }
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT);}
+#line 51 "type.pgc"
+
+ if (sqlca.sqlcode)
+ {
+ printf ("create error = %ld\n", sqlca.sqlcode);
+ exit (sqlca.sqlcode);
+ }
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) ", ECPGt_EOIT, ECPGt_EORT);}
+#line 58 "type.pgc"
+
+ if (sqlca.sqlcode)
+ {
+ printf ("insert error = %ld\n", sqlca.sqlcode);
+ exit (sqlca.sqlcode);
+ }
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = ? ",
+ ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+ ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_char,&(empl.name),(long)21,(long)1,(21)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_char,(str),(long)11,(long)1,(11)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_char,&(ptr),(long)0,(long)1,(1)*sizeof(char),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_varchar,&(vc),(long)10,(long)1,sizeof(struct varchar_vc),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 68 "type.pgc"
+
+ if (sqlca.sqlcode)
+ {
+ printf ("select error = %ld\n", sqlca.sqlcode);
+ exit (sqlca.sqlcode);
+ }
+ printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text);
+
+ { ECPGdisconnect(__LINE__, "CURRENT");}
+#line 76 "type.pgc"
+
+ exit (0);
+}
--- /dev/null
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 50: QUERY: create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 50 Ok: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 58: QUERY: insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 58 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 65: QUERY: select idnum , name , accs , string1 , string2 , string3 from empl where idnum = 1 on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 65: Correctly got 1 tuples with 6 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: 1 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: user name offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: 320 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: first str offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGstore_result: line 65: allocating memory for 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: second str offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: third str offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection regress1 closed.
+[NO_PID]: sqlca: code: 0, state: 00000
--- /dev/null
+id=1 name='user name ' accs=320 str='first str ' ptr='second str' vc='third str '
--- /dev/null
+/* Processed by ecpg (4.2.1) */
+/* These include files are added by the preprocessor */
+#include <ecpgtype.h>
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+
+#line 1 "variable.pgc"
+#include <stdlib.h>
+#include <string.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 4 "variable.pgc"
+
+
+/* exec sql whenever sqlerror sqlprint ; */
+#line 6 "variable.pgc"
+
+
+/* exec sql type c is char reference */
+#line 8 "variable.pgc"
+
+typedef char* c;
+
+/* exec sql type ind is union {
+#line 11 "variable.pgc"
+ int integer ;
+
+#line 11 "variable.pgc"
+ short smallint ;
+ } */
+#line 11 "variable.pgc"
+
+typedef union { int integer; short smallint; } ind;
+
+#define BUFFERSIZ 8
+/* exec sql type str is [ BUFFERSIZ ] */
+#line 15 "variable.pgc"
+
+
+/* declare cur cursor for select name , born , age , married , children from family */
+#line 18 "variable.pgc"
+
+
+int
+main (void)
+{
+ struct birthinfo {
+#line 23 "variable.pgc"
+ long born ;
+
+#line 23 "variable.pgc"
+ short age ;
+ } ;
+#line 23 "variable.pgc"
+
+/* exec sql begin declare section */
+
+
+
+
+
+
+
+
+#line 27 "variable.pgc"
+ struct personal_struct {
+#line 25 "variable.pgc"
+ struct varchar_name { int len; char arr[ BUFFERSIZ ]; } name ;
+
+#line 26 "variable.pgc"
+ struct birthinfo birth ;
+ } personal , * p ;
+
+#line 30 "variable.pgc"
+ struct personal_indicator {
+#line 28 "variable.pgc"
+ int ind_name ;
+
+#line 29 "variable.pgc"
+ struct birthinfo ind_birth ;
+ } ind_personal , * i ;
+
+#line 31 "variable.pgc"
+ ind ind_children ;
+/* exec sql end declare section */
+#line 32 "variable.pgc"
+
+
+
+#line 34 "variable.pgc"
+ char * married = NULL ;
+
+#line 34 "variable.pgc"
+
+
+#line 35 "variable.pgc"
+ long ind_married ;
+
+#line 35 "variable.pgc"
+
+
+#line 36 "variable.pgc"
+ ind children ;
+
+#line 36 "variable.pgc"
+
+
+ char msg[128];
+
+ ECPGdebug(1, stderr);
+
+ strcpy(msg, "connect");
+ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
+#line 43 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 43 "variable.pgc"
+
+
+ strcpy(msg, "create");
+ { ECPGdo(__LINE__, 0, 1, NULL, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 46 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 46 "variable.pgc"
+
+
+ strcpy(msg, "insert");
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 49 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 49 "variable.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 50 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 50 "variable.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 51 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 51 "variable.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 52 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 52 "variable.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 53 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 53 "variable.pgc"
+
+
+ strcpy(msg, "commit");
+ { ECPGtrans(__LINE__, NULL, "commit");
+#line 56 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 56 "variable.pgc"
+
+
+ strcpy(msg, "open");
+ { ECPGdo(__LINE__, 0, 1, NULL, "declare cur cursor for select name , born , age , married , children from family ", ECPGt_EOIT, ECPGt_EORT);
+#line 59 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 59 "variable.pgc"
+
+
+ /* exec sql whenever not found break ; */
+#line 61 "variable.pgc"
+
+
+ p=&personal;
+ i=&ind_personal;
+ memset(i, 0, sizeof(ind_personal));
+ while (1) {
+ strcpy(msg, "fetch");
+ { ECPGdo(__LINE__, 0, 1, NULL, "fetch cur", ECPGt_EOIT,
+ ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)1,sizeof(struct varchar_name),
+ ECPGt_int,&(i->ind_name),(long)1,(long)1,sizeof(int),
+ ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof(long),
+ ECPGt_long,&(i->ind_birth.born),(long)1,(long)1,sizeof(long),
+ ECPGt_short,&(p->birth.age),(long)1,(long)1,sizeof(short),
+ ECPGt_short,&(i->ind_birth.age),(long)1,(long)1,sizeof(short),
+ ECPGt_char,&(married),(long)0,(long)1,(1)*sizeof(char),
+ ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long),
+ ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int),
+ ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT);
+#line 68 "variable.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 68 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 68 "variable.pgc"
+
+ printf("%8.8s", personal.name.arr);
+ if (i->ind_birth.born >= 0)
+ printf(", born %ld", personal.birth.born);
+ if (i->ind_birth.age >= 0)
+ printf(", age = %d", personal.birth.age);
+ if (ind_married >= 0)
+ printf(", married %s", married);
+ if (ind_children.smallint >= 0)
+ printf(", children = %d", children.integer);
+ putchar('\n');
+
+ free(married);
+ married = NULL;
+ }
+
+ strcpy(msg, "close");
+ { ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT);
+#line 85 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 85 "variable.pgc"
+
+
+ strcpy(msg, "drop");
+ { ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT);
+#line 88 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 88 "variable.pgc"
+
+
+ strcpy(msg, "commit");
+ { ECPGtrans(__LINE__, NULL, "commit");
+#line 91 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 91 "variable.pgc"
+
+
+ strcpy(msg, "disconnect");
+ { ECPGdisconnect(__LINE__, "CURRENT");
+#line 94 "variable.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 94 "variable.pgc"
+
+
+ return (0);
+}
--- /dev/null
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 46: QUERY: create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 46 Ok: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 49: QUERY: insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 49 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 50: QUERY: insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 50 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 51: QUERY: insert into family ( name , age ) values ( 'Child 1' , 16 ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 51 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 52: QUERY: insert into family ( name , age ) values ( 'Child 2' , 14 ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 52 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 53: QUERY: insert into family ( name , age ) values ( 'Child 3' , 9 ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 53 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans line 56 action = commit connection = regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 59: QUERY: declare cur cursor for select name , born , age , married , children from family on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 59 Ok: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: Mum offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: 07-14-1987 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: 3 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: Dad offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: 19610721 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: 07-14-1987 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: 3 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: Child 1 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: 16 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: Child 2 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: 14 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: Child 3 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: 9 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 68: Correctly got 0 tuples with 5 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 in line 68, 'No data found in line 68.'.
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGexecute line 85: QUERY: close cur on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 85 Ok: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 88: QUERY: drop table family on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 88 Ok: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans line 91 action = commit connection = regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection regress1 closed.
+[NO_PID]: sqlca: code: 0, state: 00000
--- /dev/null
+Mum , married 07-14-1987, children = 3
+Dad , born 19610721, married 07-14-1987, children = 3
+Child 1 , age = 16
+Child 2 , age = 14
+Child 3 , age = 9
TESTS = define define.c \
- init init.c
+ init init.c \
+ type type.c \
+ variable variable.c
all: $(TESTS)
-#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
-EXEC SQL include ../regression;
+exec sql include ../regression;
-EXEC SQL typedef long mmInteger;
-EXEC SQL typedef char mmChar;
-EXEC SQL typedef short mmSmallInt;
+exec sql whenever sqlerror sqlprint;
-EXEC SQL BEGIN DECLARE SECTION;
-struct TBempl
-{
- mmInteger idnum;
- mmChar name[21];
- mmSmallInt accs;
-};
-EXEC SQL END DECLARE SECTION;
+exec sql define AMOUNT 6;
+exec sql define NAMELEN 8;
+
+exec sql type intarray is int[AMOUNT];
+typedef int intarray[AMOUNT];
int
-main (void)
+main(void)
{
- EXEC SQL BEGIN DECLARE SECTION;
- struct TBempl empl;
- EXEC SQL END DECLARE SECTION;
-
- ECPGdebug (1, stderr);
-
- empl.idnum = 1;
- EXEC SQL connect to REGRESSDB1;
- if (sqlca.sqlcode)
- {
- printf ("connect error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
-
- EXEC SQL create table empl
- (idnum integer, name char (20), accs smallint);
- if (sqlca.sqlcode)
- {
- printf ("create error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
-
- EXEC SQL insert into empl values (1, 'first user', 320);
- if (sqlca.sqlcode)
- {
- printf ("insert error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
-
- EXEC SQL select idnum, name, accs
- into :empl
- from empl
- where idnum =:empl.idnum;
- if (sqlca.sqlcode)
- {
- printf ("select error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
- printf ("id=%ld name=%s, accs=%d\n", empl.idnum, empl.name, empl.accs);
-
- EXEC SQL disconnect;
- exit (0);
+exec sql begin declare section;
+exec sql ifdef NAMELEN;
+ typedef char string[NAMELEN];
+ intarray amount;
+ char name[AMOUNT][NAMELEN];
+ char letter[AMOUNT][1];
+#if 0
+ int not_used;
+#endif
+exec sql endif;
+exec sql end declare section;
+ int i,j;
+
+ ECPGdebug(1, stderr);
+
+ exec sql connect to REGRESSDB1;
+
+ exec sql create table test (name char(NAMELEN), amount int, letter char(1));
+ exec sql commit;
+
+ exec sql insert into Test (name, amount, letter) values ('false', 1, 'f');
+ exec sql insert into test (name, amount, letter) values ('true', 2, 't');
+ exec sql commit;
+
+ exec sql select * into :name, :amount, :letter from test;
+
+ for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
+ {
+ exec sql begin declare section;
+ char n[8], l = letter[i][0];
+ int a = amount[i];
+ exec sql end declare section;
+
+ strncpy(n, name[i], NAMELEN);
+ printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
+ }
+
+ exec sql drop table test;
+ exec sql commit;
+ exec sql disconnect;
+
+ return (0);
}
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+
+EXEC SQL include ../regression;
+
+EXEC SQL typedef long mmInteger;
+EXEC SQL typedef char mmChar;
+EXEC SQL typedef short mmSmallInt;
+
+exec sql type string is char[11];
+typedef char string[11];
+
+exec sql type c is char reference;
+typedef char* c;
+
+EXEC SQL BEGIN DECLARE SECTION;
+struct TBempl
+{
+ mmInteger idnum;
+ mmChar name[21];
+ mmSmallInt accs;
+};
+EXEC SQL END DECLARE SECTION;
+
+int
+main (void)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ struct TBempl empl;
+ string str;
+ c ptr = NULL;
+ struct varchar_vc
+ {
+ int len;
+ char text[10];
+ } vc;
+ EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL var vc is varchar[10];
+ ECPGdebug (1, stderr);
+
+ empl.idnum = 1;
+ EXEC SQL connect to REGRESSDB1;
+ if (sqlca.sqlcode)
+ {
+ printf ("connect error = %ld\n", sqlca.sqlcode);
+ exit (sqlca.sqlcode);
+ }
+
+ EXEC SQL create table empl
+ (idnum integer, name char(20), accs smallint, string1 char(10), string2 char(10), string3 char(10));
+ if (sqlca.sqlcode)
+ {
+ printf ("create error = %ld\n", sqlca.sqlcode);
+ exit (sqlca.sqlcode);
+ }
+
+ EXEC SQL insert into empl values (1, 'user name', 320, 'first str', 'second str', 'third str');
+ if (sqlca.sqlcode)
+ {
+ printf ("insert error = %ld\n", sqlca.sqlcode);
+ exit (sqlca.sqlcode);
+ }
+
+ EXEC SQL select idnum, name, accs, string1, string2, string3
+ into :empl, :str, :ptr, :vc
+ from empl
+ where idnum =:empl.idnum;
+ if (sqlca.sqlcode)
+ {
+ printf ("select error = %ld\n", sqlca.sqlcode);
+ exit (sqlca.sqlcode);
+ }
+ printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text);
+
+ EXEC SQL disconnect;
+ exit (0);
+}
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+
+exec sql include ../regression;
+
+exec sql whenever sqlerror sqlprint;
+
+exec sql type c is char reference;
+typedef char* c;
+
+exec sql type ind is union { int integer; short smallint; };
+typedef union { int integer; short smallint; } ind;
+
+#define BUFFERSIZ 8
+exec sql type str is varchar[BUFFERSIZ];
+
+exec sql declare cur cursor for
+ select name, born, age, married, children from family;
+
+int
+main (void)
+{
+ exec sql struct birthinfo { long born; short age; };
+exec sql begin declare section;
+ struct personal_struct { str name;
+ struct birthinfo birth;
+ } personal, *p;
+ struct personal_indicator { int ind_name;
+ struct birthinfo ind_birth;
+ } ind_personal, *i;
+ ind ind_children;
+exec sql end declare section;
+
+ exec sql char *married = NULL;
+ exec sql long ind_married;
+ exec sql ind children;
+
+ char msg[128];
+
+ ECPGdebug(1, stderr);
+
+ strcpy(msg, "connect");
+ exec sql connect to REGRESSDB1;
+
+ strcpy(msg, "create");
+ exec sql create table family(name char(8), born integer, age smallint, married date, children integer);
+
+ strcpy(msg, "insert");
+ exec sql insert into family(name, married, children) values ('Mum', '19870714', 3);
+ exec sql insert into family(name, born, married, children) values ('Dad', '19610721', '19870714', 3);
+ exec sql insert into family(name, age) values ('Child 1', 16);
+ exec sql insert into family(name, age) values ('Child 2', 14);
+ exec sql insert into family(name, age) values ('Child 3', 9);
+
+ strcpy(msg, "commit");
+ exec sql commit;
+
+ strcpy(msg, "open");
+ exec sql open cur;
+
+ exec sql whenever not found do break;
+
+ p=&personal;
+ i=&ind_personal;
+ memset(i, 0, sizeof(ind_personal));
+ while (1) {
+ strcpy(msg, "fetch");
+ exec sql fetch cur into :p:i, :married:ind_married, :children.integer:ind_children.smallint;
+ printf("%8.8s", personal.name.arr);
+ if (i->ind_birth.born >= 0)
+ printf(", born %ld", personal.birth.born);
+ if (i->ind_birth.age >= 0)
+ printf(", age = %d", personal.birth.age);
+ if (ind_married >= 0)
+ printf(", married %s", married);
+ if (ind_children.smallint >= 0)
+ printf(", children = %d", children.integer);
+ putchar('\n');
+
+ free(married);
+ married = NULL;
+ }
+
+ strcpy(msg, "close");
+ exec sql close cur;
+
+ strcpy(msg, "drop");
+ exec sql drop table family;
+
+ strcpy(msg, "commit");
+ exec sql commit;
+
+ strcpy(msg, "disconnect");
+ exec sql disconnect;
+
+ return (0);
+}