1 /* Processed by ecpg (regression mode) */
2 /* These include files are added by the preprocessor */
3 #include <ecpglib.h>
4 #include <ecpgerrno.h>
5 #include <sqlca.h>
6 /* End of automatic include section */
7 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
8 
9 #line 1 "define.pgc"
10 #include <stdlib.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <stdio.h>
14 
15 
16 #line 1 "regression.h"
17 
18 
19 
20 
21 
22 
23 #line 6 "define.pgc"
24 
25 
26 /* exec sql whenever sqlerror  sqlprint ; */
27 #line 8 "define.pgc"
28 
29 
30 
31 
32 
33 /* exec sql type intarray is int [ 6 ] */
34 #line 13 "define.pgc"
35 
36 typedef int intarray[ 6];
37 
38 int
main(void)39 main(void)
40 {
41 /* exec sql begin declare section */
42 
43 	   typedef char  string [ 8 ];
44 
45 #line 21 "define.pgc"
46 
47 
48 
49 
50 
51 #line 22 "define.pgc"
52  intarray amount ;
53 
54 #line 23 "define.pgc"
55  char name [ 6 ] [ 8 ] ;
56 
57 #line 24 "define.pgc"
58  char letter [ 6 ] [ 1 ] ;
59 
60 #if 0
61 
62 #line 26 "define.pgc"
63  int not_used ;
64 
65 #endif
66 /* exec sql end declare section */
67 #line 29 "define.pgc"
68 
69 	int i,j;
70 
71 	ECPGdebug(1, stderr);
72 
73 	{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
74 #line 34 "define.pgc"
75 
76 if (sqlca.sqlcode < 0) sqlprint();}
77 #line 34 "define.pgc"
78 
79 
80 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )", ECPGt_EOIT, ECPGt_EORT);
81 #line 36 "define.pgc"
82 
83 if (sqlca.sqlcode < 0) sqlprint();}
84 #line 36 "define.pgc"
85 
86 	{ ECPGtrans(__LINE__, NULL, "commit");
87 #line 37 "define.pgc"
88 
89 if (sqlca.sqlcode < 0) sqlprint();}
90 #line 37 "define.pgc"
91 
92 
93 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' )", ECPGt_EOIT, ECPGt_EORT);
94 #line 39 "define.pgc"
95 
96 if (sqlca.sqlcode < 0) sqlprint();}
97 #line 39 "define.pgc"
98 
99 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' )", ECPGt_EOIT, ECPGt_EORT);
100 #line 40 "define.pgc"
101 
102 if (sqlca.sqlcode < 0) sqlprint();}
103 #line 40 "define.pgc"
104 
105 	{ ECPGtrans(__LINE__, NULL, "commit");
106 #line 41 "define.pgc"
107 
108 if (sqlca.sqlcode < 0) sqlprint();}
109 #line 41 "define.pgc"
110 
111 
112 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT,
113 	ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char),
114 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
115 	ECPGt_int,(amount),(long)1,(long)6,sizeof(int),
116 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
117 	ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char),
118 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
119 #line 43 "define.pgc"
120 
121 if (sqlca.sqlcode < 0) sqlprint();}
122 #line 43 "define.pgc"
123 
124 
125 	for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
126 	{
127 		/* exec sql begin declare section */
128 
129 
130 
131 
132 #line 48 "define.pgc"
133  string n ;
134 
135 #line 49 "define.pgc"
136  char l = letter [ i ] [ 0 ] ;
137 
138 #line 50 "define.pgc"
139  int a = amount [ i ] ;
140 /* exec sql end declare section */
141 #line 51 "define.pgc"
142 
143 
144 		strncpy(n, name[i],  8);
145 		printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
146 	}
147 
148 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
149 #line 57 "define.pgc"
150 
151 if (sqlca.sqlcode < 0) sqlprint();}
152 #line 57 "define.pgc"
153 
154 	{ ECPGtrans(__LINE__, NULL, "commit");
155 #line 58 "define.pgc"
156 
157 if (sqlca.sqlcode < 0) sqlprint();}
158 #line 58 "define.pgc"
159 
160 	{ ECPGdisconnect(__LINE__, "CURRENT");
161 #line 59 "define.pgc"
162 
163 if (sqlca.sqlcode < 0) sqlprint();}
164 #line 59 "define.pgc"
165 
166 
167 	return (0);
168 }
169