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 "desc.pgc"
10 
11 #line 1 "regression.h"
12 
13 
14 
15 
16 
17 
18 #line 1 "desc.pgc"
19 
20 /* exec sql whenever sqlerror  sqlprint ; */
21 #line 2 "desc.pgc"
22 
23 
24 int
main(void)25 main(void)
26 {
27 	/* exec sql begin declare section */
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 #line 8 "desc.pgc"
40  char * stmt1 = "INSERT INTO test1 VALUES ($1, $2)" ;
41 
42 #line 9 "desc.pgc"
43  char * stmt2 = "SELECT * from test1 where a = $1 and b = $2" ;
44 
45 #line 10 "desc.pgc"
46  char * stmt3 = "SELECT * from test1 where :var = a" ;
47 
48 #line 12 "desc.pgc"
49  int val1 = 1 ;
50 
51 #line 13 "desc.pgc"
52  char val2 [ 4 ] = "one" , val2output [] = "AAA" ;
53 
54 #line 14 "desc.pgc"
55  int val1output = 2 , val2i = 0 ;
56 
57 #line 15 "desc.pgc"
58  int val2null = - 1 ;
59 
60 #line 16 "desc.pgc"
61  int ind1 , ind2 ;
62 
63 #line 17 "desc.pgc"
64  char desc1 [ 8 ] = "outdesc" ;
65 /* exec sql end declare section */
66 #line 18 "desc.pgc"
67 
68 
69 	ECPGdebug(1, stderr);
70 
71 	ECPGallocate_desc(__LINE__, "indesc");
72 #line 22 "desc.pgc"
73 
74 if (sqlca.sqlcode < 0) sqlprint();
75 #line 22 "desc.pgc"
76 
77 	ECPGallocate_desc(__LINE__, (desc1));
78 #line 23 "desc.pgc"
79 
80 if (sqlca.sqlcode < 0) sqlprint();
81 #line 23 "desc.pgc"
82 
83 
84 	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
85 	ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
86 
87 #line 25 "desc.pgc"
88 
89 if (sqlca.sqlcode < 0) sqlprint();}
90 #line 25 "desc.pgc"
91 
92 	{ ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
93 	ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
94 	ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT);
95 
96 #line 26 "desc.pgc"
97 
98 if (sqlca.sqlcode < 0) sqlprint();}
99 #line 26 "desc.pgc"
100 
101 
102 	{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
103 #line 28 "desc.pgc"
104 
105 if (sqlca.sqlcode < 0) sqlprint();}
106 #line 28 "desc.pgc"
107 
108 
109 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test1 ( a int , b text )", ECPGt_EOIT, ECPGt_EORT);
110 #line 30 "desc.pgc"
111 
112 if (sqlca.sqlcode < 0) sqlprint();}
113 #line 30 "desc.pgc"
114 
115 	{ ECPGprepare(__LINE__, NULL, 0, "foo1", stmt1);
116 #line 31 "desc.pgc"
117 
118 if (sqlca.sqlcode < 0) sqlprint();}
119 #line 31 "desc.pgc"
120 
121 	{ ECPGprepare(__LINE__, NULL, 0, "Foo-1", stmt1);
122 #line 32 "desc.pgc"
123 
124 if (sqlca.sqlcode < 0) sqlprint();}
125 #line 32 "desc.pgc"
126 
127 	{ ECPGprepare(__LINE__, NULL, 0, "foo2", stmt2);
128 #line 33 "desc.pgc"
129 
130 if (sqlca.sqlcode < 0) sqlprint();}
131 #line 33 "desc.pgc"
132 
133 	{ ECPGprepare(__LINE__, NULL, 0, "foo3", stmt3);
134 #line 34 "desc.pgc"
135 
136 if (sqlca.sqlcode < 0) sqlprint();}
137 #line 34 "desc.pgc"
138 
139 
140 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo1",
141 	ECPGt_descriptor, "indesc", 1L, 1L, 1L,
142 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
143 #line 36 "desc.pgc"
144 
145 if (sqlca.sqlcode < 0) sqlprint();}
146 #line 36 "desc.pgc"
147 
148 
149 	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
150 	ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT);
151 
152 #line 38 "desc.pgc"
153 
154 if (sqlca.sqlcode < 0) sqlprint();}
155 #line 38 "desc.pgc"
156 
157 	{ ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
158 	ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
159 	ECPGt_int,&(val2null),(long)1,(long)1,sizeof(int), ECPGd_EODT);
160 
161 #line 39 "desc.pgc"
162 
163 if (sqlca.sqlcode < 0) sqlprint();}
164 #line 39 "desc.pgc"
165 
166 
167 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo1",
168 	ECPGt_descriptor, "indesc", 1L, 1L, 1L,
169 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
170 #line 41 "desc.pgc"
171 
172 if (sqlca.sqlcode < 0) sqlprint();}
173 #line 41 "desc.pgc"
174 
175 
176 	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
177 	ECPGt_const,"3",(long)1,(long)1,strlen("3"), ECPGd_EODT);
178 
179 #line 43 "desc.pgc"
180 
181 if (sqlca.sqlcode < 0) sqlprint();}
182 #line 43 "desc.pgc"
183 
184 	{ ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
185 	ECPGt_const,"this is a long test",(long)19,(long)1,strlen("this is a long test"), ECPGd_indicator,
186 	ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
187 
188 #line 44 "desc.pgc"
189 
190 if (sqlca.sqlcode < 0) sqlprint();}
191 #line 44 "desc.pgc"
192 
193 
194 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "Foo-1",
195 	ECPGt_descriptor, "indesc", 1L, 1L, 1L,
196 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
197 #line 46 "desc.pgc"
198 
199 if (sqlca.sqlcode < 0) sqlprint();}
200 #line 46 "desc.pgc"
201 
202 
203 	{ ECPGdeallocate(__LINE__, 0, NULL, "Foo-1");
204 #line 48 "desc.pgc"
205 
206 if (sqlca.sqlcode < 0) sqlprint();}
207 #line 48 "desc.pgc"
208 
209 
210 	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
211 	ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
212 
213 #line 50 "desc.pgc"
214 
215 if (sqlca.sqlcode < 0) sqlprint();}
216 #line 50 "desc.pgc"
217 
218 	{ ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
219 	ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
220 	ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT);
221 
222 #line 51 "desc.pgc"
223 
224 if (sqlca.sqlcode < 0) sqlprint();}
225 #line 51 "desc.pgc"
226 
227 
228 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo2",
229 	ECPGt_descriptor, "indesc", 1L, 1L, 1L,
230 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
231 	ECPGt_descriptor, (desc1), 1L, 1L, 1L,
232 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
233 #line 53 "desc.pgc"
234 
235 if (sqlca.sqlcode < 0) sqlprint();}
236 #line 53 "desc.pgc"
237 
238 
239 	{ ECPGget_desc(__LINE__, (desc1), 1,ECPGd_data,
240 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT);
241 
242 #line 55 "desc.pgc"
243 
244 if (sqlca.sqlcode < 0) sqlprint();}
245 #line 55 "desc.pgc"
246 
247 	printf("output = %s\n", val2output);
248 
249 	/* declare c1 cursor for $1 */
250 #line 58 "desc.pgc"
251 
252 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c1 cursor for $1",
253 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
254 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
255 	ECPGt_descriptor, "indesc", 1L, 1L, 1L,
256 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
257 #line 59 "desc.pgc"
258 
259 if (sqlca.sqlcode < 0) sqlprint();}
260 #line 59 "desc.pgc"
261 
262 
263 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c1", ECPGt_EOIT,
264 	ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
265 	ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int),
266 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
267 	ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT);
268 #line 61 "desc.pgc"
269 
270 if (sqlca.sqlcode < 0) sqlprint();}
271 #line 61 "desc.pgc"
272 
273 	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
274 		val1output, ind1, val2output, ind2);
275 
276 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c1", ECPGt_EOIT, ECPGt_EORT);
277 #line 65 "desc.pgc"
278 
279 if (sqlca.sqlcode < 0) sqlprint();}
280 #line 65 "desc.pgc"
281 
282 
283 	{ ECPGset_desc_header(__LINE__, "indesc", (int)(1));
284 
285 #line 67 "desc.pgc"
286 
287 if (sqlca.sqlcode < 0) sqlprint();}
288 #line 67 "desc.pgc"
289 
290 	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
291 	ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT);
292 
293 #line 68 "desc.pgc"
294 
295 if (sqlca.sqlcode < 0) sqlprint();}
296 #line 68 "desc.pgc"
297 
298 
299 	/* declare c2 cursor for $1 */
300 #line 70 "desc.pgc"
301 
302 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c2 cursor for $1",
303 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo3", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
304 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
305 	ECPGt_descriptor, "indesc", 1L, 1L, 1L,
306 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
307 #line 71 "desc.pgc"
308 
309 if (sqlca.sqlcode < 0) sqlprint();}
310 #line 71 "desc.pgc"
311 
312 
313 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c2", ECPGt_EOIT,
314 	ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
315 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
316 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
317 	ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
318 #line 73 "desc.pgc"
319 
320 if (sqlca.sqlcode < 0) sqlprint();}
321 #line 73 "desc.pgc"
322 
323 	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
324 
325 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c2", ECPGt_EOIT, ECPGt_EORT);
326 #line 76 "desc.pgc"
327 
328 if (sqlca.sqlcode < 0) sqlprint();}
329 #line 76 "desc.pgc"
330 
331 
332 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test1 where a = 3", ECPGt_EOIT,
333 	ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
334 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
335 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
336 	ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
337 #line 78 "desc.pgc"
338 
339 if (sqlca.sqlcode < 0) sqlprint();}
340 #line 78 "desc.pgc"
341 
342 	printf("val1=%d val2=%c%c%c%c warn=%c truncate=%d\n", val1output, val2output[0], val2output[1], val2output[2], val2output[3], sqlca.sqlwarn[0], val2i);
343 
344 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test1", ECPGt_EOIT, ECPGt_EORT);
345 #line 81 "desc.pgc"
346 
347 if (sqlca.sqlcode < 0) sqlprint();}
348 #line 81 "desc.pgc"
349 
350 	{ ECPGdeallocate_all(__LINE__, 0, NULL);
351 #line 82 "desc.pgc"
352 
353 if (sqlca.sqlcode < 0) sqlprint();}
354 #line 82 "desc.pgc"
355 
356 	{ ECPGdisconnect(__LINE__, "CURRENT");
357 #line 83 "desc.pgc"
358 
359 if (sqlca.sqlcode < 0) sqlprint();}
360 #line 83 "desc.pgc"
361 
362 
363 	ECPGdeallocate_desc(__LINE__, "indesc");
364 #line 85 "desc.pgc"
365 
366 if (sqlca.sqlcode < 0) sqlprint();
367 #line 85 "desc.pgc"
368 
369 	ECPGdeallocate_desc(__LINE__, (desc1));
370 #line 86 "desc.pgc"
371 
372 if (sqlca.sqlcode < 0) sqlprint();
373 #line 86 "desc.pgc"
374 
375 
376 	return 0;
377 }
378