PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
preproc-cursor.c
Go to the documentation of this file.
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 "cursor.pgc"
10 #include <stdlib.h>
11 #include <string.h>
12 
13 
14 #line 1 "regression.h"
15 
16 
17 
18 
19 
20 
21 #line 4 "cursor.pgc"
22 
23 
24 /* exec sql whenever sqlerror stop ; */
25 #line 6 "cursor.pgc"
26 
27 
28 /* exec sql type c is char reference */
29 #line 8 "cursor.pgc"
30 
31 typedef char* c;
32 
33 /* exec sql type ind is union {
34 #line 11 "cursor.pgc"
35  int integer ;
36 
37 #line 11 "cursor.pgc"
38  short smallint ;
39  } */
40 #line 11 "cursor.pgc"
41 
42 typedef union { int integer; short smallint; } ind;
43 
44 #define BUFFERSIZ 8
45 /* exec sql type str is [ BUFFERSIZ ] */
46 #line 15 "cursor.pgc"
47 
48 
49 #define CURNAME "mycur"
50 
51 int
52 main (void)
53 {
54 /* exec sql begin declare section */
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 #line 23 "cursor.pgc"
66  char * stmt1 = "SELECT id, t FROM t1" ;
67 
68 #line 24 "cursor.pgc"
69  char * curname1 = CURNAME ;
70 
71 #line 25 "cursor.pgc"
72  char * curname2 = CURNAME ;
73 
74 #line 26 "cursor.pgc"
75  char * curname3 = CURNAME ;
76 
77 #line 27 "cursor.pgc"
78  struct varchar_1 { int len; char arr[ 50 ]; } curname4 ;
79 
80 #line 28 "cursor.pgc"
81  char * curname5 = CURNAME ;
82 
83 #line 29 "cursor.pgc"
84  int count ;
85 
86 #line 30 "cursor.pgc"
87  int id ;
88 
89 #line 31 "cursor.pgc"
90  char t [ 64 ] ;
91 /* exec sql end declare section */
92 #line 32 "cursor.pgc"
93 
94 
95  char msg[128];
96 
97  ECPGdebug(1, stderr);
98 
99  strcpy(msg, "connect");
100  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "test1", 0);
101 #line 39 "cursor.pgc"
102 
103 if (sqlca.sqlcode < 0) exit (1);}
104 #line 39 "cursor.pgc"
105 
106  { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "test2", 0);
107 #line 40 "cursor.pgc"
108 
109 if (sqlca.sqlcode < 0) exit (1);}
110 #line 40 "cursor.pgc"
111 
112 
113  strcpy(msg, "set");
114  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
115 #line 43 "cursor.pgc"
116 
117 if (sqlca.sqlcode < 0) exit (1);}
118 #line 43 "cursor.pgc"
119 
120 
121  strcpy(msg, "create");
122  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
123 #line 46 "cursor.pgc"
124 
125 if (sqlca.sqlcode < 0) exit (1);}
126 #line 46 "cursor.pgc"
127 
128  { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
129 #line 47 "cursor.pgc"
130 
131 if (sqlca.sqlcode < 0) exit (1);}
132 #line 47 "cursor.pgc"
133 
134 
135  strcpy(msg, "insert");
136  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
137 #line 50 "cursor.pgc"
138 
139 if (sqlca.sqlcode < 0) exit (1);}
140 #line 50 "cursor.pgc"
141 
142  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
143 #line 51 "cursor.pgc"
144 
145 if (sqlca.sqlcode < 0) exit (1);}
146 #line 51 "cursor.pgc"
147 
148  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
149 #line 52 "cursor.pgc"
150 
151 if (sqlca.sqlcode < 0) exit (1);}
152 #line 52 "cursor.pgc"
153 
154  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
155 #line 53 "cursor.pgc"
156 
157 if (sqlca.sqlcode < 0) exit (1);}
158 #line 53 "cursor.pgc"
159 
160  { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'e' )", ECPGt_EOIT, ECPGt_EORT);
161 #line 54 "cursor.pgc"
162 
163 if (sqlca.sqlcode < 0) exit (1);}
164 #line 54 "cursor.pgc"
165 
166 
167  strcpy(msg, "commit");
168  { ECPGtrans(__LINE__, "test1", "commit");
169 #line 57 "cursor.pgc"
170 
171 if (sqlca.sqlcode < 0) exit (1);}
172 #line 57 "cursor.pgc"
173 
174  { ECPGtrans(__LINE__, "test2", "commit");
175 #line 58 "cursor.pgc"
176 
177 if (sqlca.sqlcode < 0) exit (1);}
178 #line 58 "cursor.pgc"
179 
180 
181  /* Dynamic cursorname test with INTO list in FETCH stmts */
182 
183  strcpy(msg, "declare");
184  ECPGset_var( 0, &( curname1 ), __LINE__);\
185  /* declare $0 cursor for select id , t from t1 */
186 #line 64 "cursor.pgc"
187 
188 
189  strcpy(msg, "open");
190  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
191  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
192  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
193 #line 67 "cursor.pgc"
194 
195 if (sqlca.sqlcode < 0) exit (1);}
196 #line 67 "cursor.pgc"
197 
198 
199  strcpy(msg, "fetch from");
200  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward from $0",
201  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
202  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
203  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
204  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
205  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
206  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
207 #line 70 "cursor.pgc"
208 
209 if (sqlca.sqlcode < 0) exit (1);}
210 #line 70 "cursor.pgc"
211 
212  printf("%d %s\n", id, t);
213 
214  strcpy(msg, "fetch");
215  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0",
216  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
217  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
218  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
219  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
220  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
221  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
222 #line 74 "cursor.pgc"
223 
224 if (sqlca.sqlcode < 0) exit (1);}
225 #line 74 "cursor.pgc"
226 
227  printf("%d %s\n", id, t);
228 
229  strcpy(msg, "fetch 1 from");
230  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
231  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
232  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
233  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
234  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
235  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
236  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
237 #line 78 "cursor.pgc"
238 
239 if (sqlca.sqlcode < 0) exit (1);}
240 #line 78 "cursor.pgc"
241 
242  printf("%d %s\n", id, t);
243 
244  strcpy(msg, "fetch :count from");
245  count = 1;
246  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
247  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
248  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
249  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
250  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
251  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
252  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
253  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
254  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
255 #line 83 "cursor.pgc"
256 
257 if (sqlca.sqlcode < 0) exit (1);}
258 #line 83 "cursor.pgc"
259 
260  printf("%d %s\n", id, t);
261 
262  strcpy(msg, "move in");
263  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 in $0",
264  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
265  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
266 #line 87 "cursor.pgc"
267 
268 if (sqlca.sqlcode < 0) exit (1);}
269 #line 87 "cursor.pgc"
270 
271 
272  strcpy(msg, "fetch 1");
273  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0",
274  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
275  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
276  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
277  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
278  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
279  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
280 #line 90 "cursor.pgc"
281 
282 if (sqlca.sqlcode < 0) exit (1);}
283 #line 90 "cursor.pgc"
284 
285  printf("%d %s\n", id, t);
286 
287  strcpy(msg, "fetch :count");
288  count = 1;
289  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
290  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
291  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
292  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
293  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
294  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
295  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
296  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
297  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
298 #line 95 "cursor.pgc"
299 
300 if (sqlca.sqlcode < 0) exit (1);}
301 #line 95 "cursor.pgc"
302 
303  printf("%d %s\n", id, t);
304 
305  strcpy(msg, "close");
306  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
307  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
308  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
309 #line 99 "cursor.pgc"
310 
311 if (sqlca.sqlcode < 0) exit (1);}
312 #line 99 "cursor.pgc"
313 
314 
315  /* Dynamic cursorname test with INTO list in DECLARE stmt */
316 
317  strcpy(msg, "declare");
318  ECPGset_var( 1, &( curname2 ), __LINE__);\
319  ECPGset_var( 2, ( t ), __LINE__);\
320  ECPGset_var( 3, &( id ), __LINE__);\
321  /* declare $0 cursor for select id , t from t1 */
322 #line 105 "cursor.pgc"
323 
324 
325  strcpy(msg, "open");
326  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
327  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
328  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
329  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
330  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
331  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
332  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
333 #line 108 "cursor.pgc"
334 
335 if (sqlca.sqlcode < 0) exit (1);}
336 #line 108 "cursor.pgc"
337 
338 
339  strcpy(msg, "fetch from");
340  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
341  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
342  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
343  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
344  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
345  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
346  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
347 #line 111 "cursor.pgc"
348 
349 if (sqlca.sqlcode < 0) exit (1);}
350 #line 111 "cursor.pgc"
351 
352  printf("%d %s\n", id, t);
353 
354  strcpy(msg, "fetch");
355  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0",
356  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
357  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
358  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
359  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
360  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
361  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
362 #line 115 "cursor.pgc"
363 
364 if (sqlca.sqlcode < 0) exit (1);}
365 #line 115 "cursor.pgc"
366 
367  printf("%d %s\n", id, t);
368 
369  strcpy(msg, "fetch 1 from");
370  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
371  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
372  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
373  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
374  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
375  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
376  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
377 #line 119 "cursor.pgc"
378 
379 if (sqlca.sqlcode < 0) exit (1);}
380 #line 119 "cursor.pgc"
381 
382  printf("%d %s\n", id, t);
383 
384  strcpy(msg, "fetch :count from");
385  count = 1;
386  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
387  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
388  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
389  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
390  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
391  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
392  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
393  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
394  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
395 #line 124 "cursor.pgc"
396 
397 if (sqlca.sqlcode < 0) exit (1);}
398 #line 124 "cursor.pgc"
399 
400  printf("%d %s\n", id, t);
401 
402  strcpy(msg, "move");
403  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
404  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
405  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
406  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
407  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
408  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
409  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
410 #line 128 "cursor.pgc"
411 
412 if (sqlca.sqlcode < 0) exit (1);}
413 #line 128 "cursor.pgc"
414 
415 
416  strcpy(msg, "fetch 1");
417  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0",
418  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
419  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
420  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
421  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
422  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
423  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
424 #line 131 "cursor.pgc"
425 
426 if (sqlca.sqlcode < 0) exit (1);}
427 #line 131 "cursor.pgc"
428 
429  printf("%d %s\n", id, t);
430 
431  strcpy(msg, "fetch :count");
432  count = 1;
433  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
434  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
435  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
436  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
437  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
438  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
439  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
440  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
441  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
442 #line 136 "cursor.pgc"
443 
444 if (sqlca.sqlcode < 0) exit (1);}
445 #line 136 "cursor.pgc"
446 
447  printf("%d %s\n", id, t);
448 
449  strcpy(msg, "close");
450  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
451  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
452  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
453 #line 140 "cursor.pgc"
454 
455 if (sqlca.sqlcode < 0) exit (1);}
456 #line 140 "cursor.pgc"
457 
458 
459  /* Dynamic cursorname test with PREPARED stmt */
460 
461  strcpy(msg, "prepare");
462  { ECPGprepare(__LINE__, "test1", 0, "st_id1", stmt1);
463 #line 145 "cursor.pgc"
464 
465 if (sqlca.sqlcode < 0) exit (1);}
466 #line 145 "cursor.pgc"
467 
468  { ECPGprepare(__LINE__, "test2", 0, "st_id1", stmt1);
469 #line 146 "cursor.pgc"
470 
471 if (sqlca.sqlcode < 0) exit (1);}
472 #line 146 "cursor.pgc"
473 
474 
475  strcpy(msg, "declare");
476  ECPGset_var( 4, &( curname3 ), __LINE__);\
477  /* declare $0 cursor for $1 */
478 #line 149 "cursor.pgc"
479 
480  ECPGset_var( 5, &( curname5 ), __LINE__);\
481  /* declare $0 cursor for $1 */
482 #line 150 "cursor.pgc"
483 
484 
485  strcpy(msg, "open");
486  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1",
487  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
488  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
489  ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
490  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
491 #line 153 "cursor.pgc"
492 
493 if (sqlca.sqlcode < 0) exit (1);}
494 #line 153 "cursor.pgc"
495 
496  { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "declare $0 cursor for $1",
497  ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char),
498  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
499  ECPGt_char_variable,(ECPGprepared_statement("test2", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
500  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
501 #line 154 "cursor.pgc"
502 
503 if (sqlca.sqlcode < 0) exit (1);}
504 #line 154 "cursor.pgc"
505 
506 
507  strcpy(msg, "fetch");
508  { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "fetch $0",
509  ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char),
510  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
511  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
512  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
513  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
514  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
515 #line 157 "cursor.pgc"
516 
517 if (sqlca.sqlcode < 0) exit (1);}
518 #line 157 "cursor.pgc"
519 
520  printf("%d %s\n", id, t);
521 
522  strcpy(msg, "fetch from");
523  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
524  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
525  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
526  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
527  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
528  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
529  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
530 #line 161 "cursor.pgc"
531 
532 if (sqlca.sqlcode < 0) exit (1);}
533 #line 161 "cursor.pgc"
534 
535  printf("%d %s\n", id, t);
536 
537  strcpy(msg, "fetch 1 from");
538  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
539  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
540  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
541  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
542  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
543  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
544  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
545 #line 165 "cursor.pgc"
546 
547 if (sqlca.sqlcode < 0) exit (1);}
548 #line 165 "cursor.pgc"
549 
550  printf("%d %s\n", id, t);
551 
552  strcpy(msg, "fetch :count from");
553  count = 1;
554  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
555  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
556  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
557  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
558  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
559  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
560  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
561  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
562  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
563 #line 170 "cursor.pgc"
564 
565 if (sqlca.sqlcode < 0) exit (1);}
566 #line 170 "cursor.pgc"
567 
568  printf("%d %s\n", id, t);
569 
570  strcpy(msg, "move");
571  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
572  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
573  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
574 #line 174 "cursor.pgc"
575 
576 if (sqlca.sqlcode < 0) exit (1);}
577 #line 174 "cursor.pgc"
578 
579 
580  strcpy(msg, "fetch 1");
581  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0",
582  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
583  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
584  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
585  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
586  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
587  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
588 #line 177 "cursor.pgc"
589 
590 if (sqlca.sqlcode < 0) exit (1);}
591 #line 177 "cursor.pgc"
592 
593  printf("%d %s\n", id, t);
594 
595  strcpy(msg, "fetch :count");
596  count = 1;
597  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
598  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
599  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
600  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
601  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
602  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
603  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
604  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
605  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
606 #line 182 "cursor.pgc"
607 
608 if (sqlca.sqlcode < 0) exit (1);}
609 #line 182 "cursor.pgc"
610 
611  printf("%d %s\n", id, t);
612 
613  strcpy(msg, "close");
614  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
615  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
616  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
617 #line 186 "cursor.pgc"
618 
619 if (sqlca.sqlcode < 0) exit (1);}
620 #line 186 "cursor.pgc"
621 
622  { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "close $0",
623  ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char),
624  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
625 #line 187 "cursor.pgc"
626 
627 if (sqlca.sqlcode < 0) exit (1);}
628 #line 187 "cursor.pgc"
629 
630 
631  strcpy(msg, "deallocate prepare");
632  { ECPGdeallocate(__LINE__, 0, "test1", "st_id1");
633 #line 190 "cursor.pgc"
634 
635 if (sqlca.sqlcode < 0) exit (1);}
636 #line 190 "cursor.pgc"
637 
638  { ECPGdeallocate(__LINE__, 0, "test2", "st_id1");
639 #line 191 "cursor.pgc"
640 
641 if (sqlca.sqlcode < 0) exit (1);}
642 #line 191 "cursor.pgc"
643 
644 
645  /* Dynamic cursorname test with PREPARED stmt,
646  cursor name in varchar */
647 
648  curname4.len = strlen(CURNAME);
649  strcpy(curname4.arr, CURNAME);
650 
651  strcpy(msg, "prepare");
652  { ECPGprepare(__LINE__, "test1", 0, "st_id2", stmt1);
653 #line 200 "cursor.pgc"
654 
655 if (sqlca.sqlcode < 0) exit (1);}
656 #line 200 "cursor.pgc"
657 
658 
659  strcpy(msg, "declare");
660  ECPGset_var( 6, &( curname4 ), __LINE__);\
661  /* declare $0 cursor for $1 */
662 #line 203 "cursor.pgc"
663 
664 
665  strcpy(msg, "open");
666  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1",
667  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
668  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
669  ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
670  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
671 #line 206 "cursor.pgc"
672 
673 if (sqlca.sqlcode < 0) exit (1);}
674 #line 206 "cursor.pgc"
675 
676 
677  strcpy(msg, "fetch from");
678  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
679  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
680  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
681  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
682  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
683  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
684  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
685 #line 209 "cursor.pgc"
686 
687 if (sqlca.sqlcode < 0) exit (1);}
688 #line 209 "cursor.pgc"
689 
690  printf("%d %s\n", id, t);
691 
692  strcpy(msg, "fetch");
693  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0",
694  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
695  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
696  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
697  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
698  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
699  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
700 #line 213 "cursor.pgc"
701 
702 if (sqlca.sqlcode < 0) exit (1);}
703 #line 213 "cursor.pgc"
704 
705  printf("%d %s\n", id, t);
706 
707  strcpy(msg, "fetch 1 from");
708  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
709  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
710  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
711  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
712  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
713  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
714  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
715 #line 217 "cursor.pgc"
716 
717 if (sqlca.sqlcode < 0) exit (1);}
718 #line 217 "cursor.pgc"
719 
720  printf("%d %s\n", id, t);
721 
722  strcpy(msg, "fetch :count from");
723  count = 1;
724  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
725  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
726  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
727  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
728  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
729  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
730  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
731  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
732  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
733 #line 222 "cursor.pgc"
734 
735 if (sqlca.sqlcode < 0) exit (1);}
736 #line 222 "cursor.pgc"
737 
738  printf("%d %s\n", id, t);
739 
740  strcpy(msg, "move");
741  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
742  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
743  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
744 #line 226 "cursor.pgc"
745 
746 if (sqlca.sqlcode < 0) exit (1);}
747 #line 226 "cursor.pgc"
748 
749 
750  strcpy(msg, "fetch 1");
751  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0",
752  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
753  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
754  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
755  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
756  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
757  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
758 #line 229 "cursor.pgc"
759 
760 if (sqlca.sqlcode < 0) exit (1);}
761 #line 229 "cursor.pgc"
762 
763  printf("%d %s\n", id, t);
764 
765  strcpy(msg, "fetch :count");
766  count = 1;
767  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
768  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
769  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
770  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
771  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
772  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
773  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
774  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
775  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
776 #line 234 "cursor.pgc"
777 
778 if (sqlca.sqlcode < 0) exit (1);}
779 #line 234 "cursor.pgc"
780 
781  printf("%d %s\n", id, t);
782 
783  strcpy(msg, "close");
784  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
785  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
786  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
787 #line 238 "cursor.pgc"
788 
789 if (sqlca.sqlcode < 0) exit (1);}
790 #line 238 "cursor.pgc"
791 
792 
793  strcpy(msg, "deallocate prepare");
794  { ECPGdeallocate(__LINE__, 0, "test1", "st_id2");
795 #line 241 "cursor.pgc"
796 
797 if (sqlca.sqlcode < 0) exit (1);}
798 #line 241 "cursor.pgc"
799 
800 
801  /* End test */
802 
803  strcpy(msg, "drop");
804  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
805 #line 246 "cursor.pgc"
806 
807 if (sqlca.sqlcode < 0) exit (1);}
808 #line 246 "cursor.pgc"
809 
810  { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
811 #line 247 "cursor.pgc"
812 
813 if (sqlca.sqlcode < 0) exit (1);}
814 #line 247 "cursor.pgc"
815 
816 
817  strcpy(msg, "commit");
818  { ECPGtrans(__LINE__, "test1", "commit");
819 #line 250 "cursor.pgc"
820 
821 if (sqlca.sqlcode < 0) exit (1);}
822 #line 250 "cursor.pgc"
823 
824 
825  strcpy(msg, "disconnect");
826  { ECPGdisconnect(__LINE__, "ALL");
827 #line 253 "cursor.pgc"
828 
829 if (sqlca.sqlcode < 0) exit (1);}
830 #line 253 "cursor.pgc"
831 
832 
833  return 0;
834 }
#define CURNAME
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:669
#define sqlca
Definition: sqlca.h:59
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: execute.c:2030
#define ECPGdebug(X, Y)
Definition: preproc-cursor.c:7
bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
Definition: prepare.c:161
void ECPGset_var(int number, void *pointer, int lineno)
Definition: misc.c:524
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:271
char * c
bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
Definition: prepare.c:253
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:199
int main(void)
char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
Definition: prepare.c:306
short smallint