PostgreSQL Source Code  git master
preproc-cursor.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for preproc-cursor.c:

Go to the source code of this file.

Data Structures

union  ind
 

Macros

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
 
#define BUFFERSIZ   8
 
#define CURNAME   "mycur"
 

Typedefs

typedef char * c
 

Functions

int main (void)
 

Macro Definition Documentation

◆ BUFFERSIZ

#define BUFFERSIZ   8

Definition at line 44 of file preproc-cursor.c.

◆ CURNAME

#define CURNAME   "mycur"

Definition at line 49 of file preproc-cursor.c.

Referenced by main().

◆ ECPGdebug

#define ECPGdebug (   X,
 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file preproc-cursor.c.

Referenced by main().

Typedef Documentation

◆ c

typedef char* c

Definition at line 31 of file preproc-cursor.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 52 of file preproc-cursor.c.

References CURNAME, ECPGclose(), ECPGconnect(), ECPGdeallocate(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGfetch(), ECPGopen(), ECPGprepare(), ECPGprepared_statement(), ECPGset_var(), ECPGst_normal, ECPGt_char, ECPGt_char_variable, ECPGt_EOIT, ECPGt_EORT, ECPGt_int, ECPGt_NO_INDICATOR, ECPGt_varchar, ECPGtrans(), printf, and sqlca.

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 if (sqlca.sqlcode < 0) exit (1);
189 #line 64 "cursor.pgc"
190 
191 #line 64 "cursor.pgc"
192 
193 
194  strcpy(msg, "open");
195  { ECPGopen(":curname1", NULL, __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
196  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
197  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
198 #line 67 "cursor.pgc"
199 
200 if (sqlca.sqlcode < 0) exit (1);}
201 #line 67 "cursor.pgc"
202 
203 
204  strcpy(msg, "fetch from");
205  { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward from $0",
206  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
207  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
208  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
209  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
210  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
211  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
212 #line 70 "cursor.pgc"
213 
214 if (sqlca.sqlcode < 0) exit (1);}
215 #line 70 "cursor.pgc"
216 
217  printf("%d %s\n", id, t);
218 
219  strcpy(msg, "fetch");
220  { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0",
221  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
222  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
223  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
224  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
225  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
226  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
227 #line 74 "cursor.pgc"
228 
229 if (sqlca.sqlcode < 0) exit (1);}
230 #line 74 "cursor.pgc"
231 
232  printf("%d %s\n", id, t);
233 
234  strcpy(msg, "fetch 1 from");
235  { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
236  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
237  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
238  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
239  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
240  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
241  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
242 #line 78 "cursor.pgc"
243 
244 if (sqlca.sqlcode < 0) exit (1);}
245 #line 78 "cursor.pgc"
246 
247  printf("%d %s\n", id, t);
248 
249  strcpy(msg, "fetch :count from");
250  count = 1;
251  { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
252  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
253  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
254  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
255  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
256  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
257  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
258  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
259  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
260 #line 83 "cursor.pgc"
261 
262 if (sqlca.sqlcode < 0) exit (1);}
263 #line 83 "cursor.pgc"
264 
265  printf("%d %s\n", id, t);
266 
267  strcpy(msg, "move in");
268  { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 in $0",
269  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
270  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
271 #line 87 "cursor.pgc"
272 
273 if (sqlca.sqlcode < 0) exit (1);}
274 #line 87 "cursor.pgc"
275 
276 
277  strcpy(msg, "fetch 1");
278  { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0",
279  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
280  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
281  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
282  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
283  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
284  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
285 #line 90 "cursor.pgc"
286 
287 if (sqlca.sqlcode < 0) exit (1);}
288 #line 90 "cursor.pgc"
289 
290  printf("%d %s\n", id, t);
291 
292  strcpy(msg, "fetch :count");
293  count = 1;
294  { ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
295  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
296  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
297  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
298  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
299  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
300  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
301  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
302  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
303 #line 95 "cursor.pgc"
304 
305 if (sqlca.sqlcode < 0) exit (1);}
306 #line 95 "cursor.pgc"
307 
308  printf("%d %s\n", id, t);
309 
310  strcpy(msg, "close");
311  { ECPGclose(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
312  ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
313  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
314 #line 99 "cursor.pgc"
315 
316 if (sqlca.sqlcode < 0) exit (1);}
317 #line 99 "cursor.pgc"
318 
319 
320  /* Dynamic cursorname test with INTO list in DECLARE stmt */
321 
322  strcpy(msg, "declare");
323  ECPGset_var( 1, &( curname2 ), __LINE__);\
324  ECPGset_var( 2, ( t ), __LINE__);\
325  ECPGset_var( 3, &( id ), __LINE__);\
326  /* declare $0 cursor for select id , t from t1 */
327 #line 105 "cursor.pgc"
328 
329 if (sqlca.sqlcode < 0) exit (1);
330 #line 105 "cursor.pgc"
331 
332 #line 105 "cursor.pgc"
333 
334 
335  strcpy(msg, "open");
336  { ECPGopen(":curname2", NULL, __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
337  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
338  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
339  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
340  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
341  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
342  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
343 #line 108 "cursor.pgc"
344 
345 if (sqlca.sqlcode < 0) exit (1);}
346 #line 108 "cursor.pgc"
347 
348 
349  strcpy(msg, "fetch from");
350  { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
351  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
352  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
353  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
354  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
355  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
356  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
357 #line 111 "cursor.pgc"
358 
359 if (sqlca.sqlcode < 0) exit (1);}
360 #line 111 "cursor.pgc"
361 
362  printf("%d %s\n", id, t);
363 
364  strcpy(msg, "fetch");
365  { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0",
366  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
367  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
368  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
369  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
370  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
371  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
372 #line 115 "cursor.pgc"
373 
374 if (sqlca.sqlcode < 0) exit (1);}
375 #line 115 "cursor.pgc"
376 
377  printf("%d %s\n", id, t);
378 
379  strcpy(msg, "fetch 1 from");
380  { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
381  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
382  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
383  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
384  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
385  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
386  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
387 #line 119 "cursor.pgc"
388 
389 if (sqlca.sqlcode < 0) exit (1);}
390 #line 119 "cursor.pgc"
391 
392  printf("%d %s\n", id, t);
393 
394  strcpy(msg, "fetch :count from");
395  count = 1;
396  { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
397  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
398  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
399  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
400  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
401  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
402  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
403  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
404  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
405 #line 124 "cursor.pgc"
406 
407 if (sqlca.sqlcode < 0) exit (1);}
408 #line 124 "cursor.pgc"
409 
410  printf("%d %s\n", id, t);
411 
412  strcpy(msg, "move");
413  { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
414  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
415  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
416  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
417  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
418  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
419  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
420 #line 128 "cursor.pgc"
421 
422 if (sqlca.sqlcode < 0) exit (1);}
423 #line 128 "cursor.pgc"
424 
425 
426  strcpy(msg, "fetch 1");
427  { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0",
428  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
429  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
430  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
431  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
432  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
433  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
434 #line 131 "cursor.pgc"
435 
436 if (sqlca.sqlcode < 0) exit (1);}
437 #line 131 "cursor.pgc"
438 
439  printf("%d %s\n", id, t);
440 
441  strcpy(msg, "fetch :count");
442  count = 1;
443  { ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
444  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
445  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
446  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
447  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
448  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
449  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
450  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
451  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
452 #line 136 "cursor.pgc"
453 
454 if (sqlca.sqlcode < 0) exit (1);}
455 #line 136 "cursor.pgc"
456 
457  printf("%d %s\n", id, t);
458 
459  strcpy(msg, "close");
460  { ECPGclose(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
461  ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
462  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
463 #line 140 "cursor.pgc"
464 
465 if (sqlca.sqlcode < 0) exit (1);}
466 #line 140 "cursor.pgc"
467 
468 
469  /* Dynamic cursorname test with PREPARED stmt */
470 
471  strcpy(msg, "prepare");
472  { ECPGprepare(__LINE__, "test1", 0, "st_id1", stmt1);
473 #line 145 "cursor.pgc"
474 
475 if (sqlca.sqlcode < 0) exit (1);}
476 #line 145 "cursor.pgc"
477 
478  { ECPGprepare(__LINE__, "test2", 0, "st_id1", stmt1);
479 #line 146 "cursor.pgc"
480 
481 if (sqlca.sqlcode < 0) exit (1);}
482 #line 146 "cursor.pgc"
483 
484 
485  strcpy(msg, "declare");
486  ECPGset_var( 4, &( curname3 ), __LINE__);\
487  /* declare $0 cursor for $1 */
488 #line 149 "cursor.pgc"
489 
490 if (sqlca.sqlcode < 0) exit (1);
491 #line 149 "cursor.pgc"
492 
493 #line 149 "cursor.pgc"
494 
495  ECPGset_var( 5, &( curname5 ), __LINE__);\
496  /* declare $0 cursor for $1 */
497 #line 150 "cursor.pgc"
498 
499 if (sqlca.sqlcode < 0) exit (1);
500 #line 150 "cursor.pgc"
501 
502 #line 150 "cursor.pgc"
503 
504 
505  strcpy(msg, "open");
506  { ECPGopen(":curname3", "st_id1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1",
507  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
508  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
509  ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
510  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
511 #line 153 "cursor.pgc"
512 
513 if (sqlca.sqlcode < 0) exit (1);}
514 #line 153 "cursor.pgc"
515 
516  { ECPGopen(":curname5", "st_id1", __LINE__, 0, 1, "test2", 0, ECPGst_normal, "declare $0 cursor for $1",
517  ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char),
518  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
519  ECPGt_char_variable,(ECPGprepared_statement("test2", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
520  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
521 #line 154 "cursor.pgc"
522 
523 if (sqlca.sqlcode < 0) exit (1);}
524 #line 154 "cursor.pgc"
525 
526 
527  strcpy(msg, "fetch");
528  { ECPGfetch(":curname5", __LINE__, 0, 1, "test2", 0, ECPGst_normal, "fetch $0",
529  ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char),
530  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
531  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
532  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
533  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
534  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
535 #line 157 "cursor.pgc"
536 
537 if (sqlca.sqlcode < 0) exit (1);}
538 #line 157 "cursor.pgc"
539 
540  printf("%d %s\n", id, t);
541 
542  strcpy(msg, "fetch from");
543  { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
544  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
545  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
546  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
547  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
548  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
549  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
550 #line 161 "cursor.pgc"
551 
552 if (sqlca.sqlcode < 0) exit (1);}
553 #line 161 "cursor.pgc"
554 
555  printf("%d %s\n", id, t);
556 
557  strcpy(msg, "fetch 1 from");
558  { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
559  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
560  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
561  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
562  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
563  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
564  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
565 #line 165 "cursor.pgc"
566 
567 if (sqlca.sqlcode < 0) exit (1);}
568 #line 165 "cursor.pgc"
569 
570  printf("%d %s\n", id, t);
571 
572  strcpy(msg, "fetch :count from");
573  count = 1;
574  { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
575  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
576  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
577  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
578  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
579  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
580  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
581  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
582  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
583 #line 170 "cursor.pgc"
584 
585 if (sqlca.sqlcode < 0) exit (1);}
586 #line 170 "cursor.pgc"
587 
588  printf("%d %s\n", id, t);
589 
590  strcpy(msg, "move");
591  { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
592  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
593  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
594 #line 174 "cursor.pgc"
595 
596 if (sqlca.sqlcode < 0) exit (1);}
597 #line 174 "cursor.pgc"
598 
599 
600  strcpy(msg, "fetch 1");
601  { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0",
602  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
603  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
604  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
605  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
606  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
607  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
608 #line 177 "cursor.pgc"
609 
610 if (sqlca.sqlcode < 0) exit (1);}
611 #line 177 "cursor.pgc"
612 
613  printf("%d %s\n", id, t);
614 
615  strcpy(msg, "fetch :count");
616  count = 1;
617  { ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
618  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
619  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
620  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
621  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
622  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
623  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
624  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
625  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
626 #line 182 "cursor.pgc"
627 
628 if (sqlca.sqlcode < 0) exit (1);}
629 #line 182 "cursor.pgc"
630 
631  printf("%d %s\n", id, t);
632 
633  strcpy(msg, "close");
634  { ECPGclose(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
635  ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
636  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
637 #line 186 "cursor.pgc"
638 
639 if (sqlca.sqlcode < 0) exit (1);}
640 #line 186 "cursor.pgc"
641 
642  { ECPGclose(":curname5", __LINE__, 0, 1, "test2", 0, ECPGst_normal, "close $0",
643  ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char),
644  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
645 #line 187 "cursor.pgc"
646 
647 if (sqlca.sqlcode < 0) exit (1);}
648 #line 187 "cursor.pgc"
649 
650 
651  strcpy(msg, "deallocate prepare");
652  { ECPGdeallocate(__LINE__, 0, "test1", "st_id1");
653 #line 190 "cursor.pgc"
654 
655 if (sqlca.sqlcode < 0) exit (1);}
656 #line 190 "cursor.pgc"
657 
658  { ECPGdeallocate(__LINE__, 0, "test2", "st_id1");
659 #line 191 "cursor.pgc"
660 
661 if (sqlca.sqlcode < 0) exit (1);}
662 #line 191 "cursor.pgc"
663 
664 
665  /* Dynamic cursorname test with PREPARED stmt,
666  cursor name in varchar */
667 
668  curname4.len = strlen(CURNAME);
669  strcpy(curname4.arr, CURNAME);
670 
671  strcpy(msg, "prepare");
672  { ECPGprepare(__LINE__, "test1", 0, "st_id2", stmt1);
673 #line 200 "cursor.pgc"
674 
675 if (sqlca.sqlcode < 0) exit (1);}
676 #line 200 "cursor.pgc"
677 
678 
679  strcpy(msg, "declare");
680  ECPGset_var( 6, &( curname4 ), __LINE__);\
681  /* declare $0 cursor for $1 */
682 #line 203 "cursor.pgc"
683 
684 if (sqlca.sqlcode < 0) exit (1);
685 #line 203 "cursor.pgc"
686 
687 #line 203 "cursor.pgc"
688 
689 
690  strcpy(msg, "open");
691  { ECPGopen(":curname4", "st_id2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1",
692  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
693  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
694  ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
695  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
696 #line 206 "cursor.pgc"
697 
698 if (sqlca.sqlcode < 0) exit (1);}
699 #line 206 "cursor.pgc"
700 
701 
702  strcpy(msg, "fetch from");
703  { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
704  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
705  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
706  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
707  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
708  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
709  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
710 #line 209 "cursor.pgc"
711 
712 if (sqlca.sqlcode < 0) exit (1);}
713 #line 209 "cursor.pgc"
714 
715  printf("%d %s\n", id, t);
716 
717  strcpy(msg, "fetch");
718  { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0",
719  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
720  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
721  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
722  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
723  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
724  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
725 #line 213 "cursor.pgc"
726 
727 if (sqlca.sqlcode < 0) exit (1);}
728 #line 213 "cursor.pgc"
729 
730  printf("%d %s\n", id, t);
731 
732  strcpy(msg, "fetch 1 from");
733  { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
734  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
735  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
736  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
737  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
738  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
739  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
740 #line 217 "cursor.pgc"
741 
742 if (sqlca.sqlcode < 0) exit (1);}
743 #line 217 "cursor.pgc"
744 
745  printf("%d %s\n", id, t);
746 
747  strcpy(msg, "fetch :count from");
748  count = 1;
749  { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
750  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
751  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
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 222 "cursor.pgc"
759 
760 if (sqlca.sqlcode < 0) exit (1);}
761 #line 222 "cursor.pgc"
762 
763  printf("%d %s\n", id, t);
764 
765  strcpy(msg, "move");
766  { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
767  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
768  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
769 #line 226 "cursor.pgc"
770 
771 if (sqlca.sqlcode < 0) exit (1);}
772 #line 226 "cursor.pgc"
773 
774 
775  strcpy(msg, "fetch 1");
776  { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0",
777  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
778  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
779  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
780  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
781  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
782  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
783 #line 229 "cursor.pgc"
784 
785 if (sqlca.sqlcode < 0) exit (1);}
786 #line 229 "cursor.pgc"
787 
788  printf("%d %s\n", id, t);
789 
790  strcpy(msg, "fetch :count");
791  count = 1;
792  { ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
793  ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
794  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
795  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
796  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
797  ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
798  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
799  ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
800  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
801 #line 234 "cursor.pgc"
802 
803 if (sqlca.sqlcode < 0) exit (1);}
804 #line 234 "cursor.pgc"
805 
806  printf("%d %s\n", id, t);
807 
808  strcpy(msg, "close");
809  { ECPGclose(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
810  ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
811  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
812 #line 238 "cursor.pgc"
813 
814 if (sqlca.sqlcode < 0) exit (1);}
815 #line 238 "cursor.pgc"
816 
817 
818  strcpy(msg, "deallocate prepare");
819  { ECPGdeallocate(__LINE__, 0, "test1", "st_id2");
820 #line 241 "cursor.pgc"
821 
822 if (sqlca.sqlcode < 0) exit (1);}
823 #line 241 "cursor.pgc"
824 
825 
826  /* End test */
827 
828  strcpy(msg, "drop");
829  { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
830 #line 246 "cursor.pgc"
831 
832 if (sqlca.sqlcode < 0) exit (1);}
833 #line 246 "cursor.pgc"
834 
835  { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
836 #line 247 "cursor.pgc"
837 
838 if (sqlca.sqlcode < 0) exit (1);}
839 #line 247 "cursor.pgc"
840 
841 
842  strcpy(msg, "commit");
843  { ECPGtrans(__LINE__, "test1", "commit");
844 #line 250 "cursor.pgc"
845 
846 if (sqlca.sqlcode < 0) exit (1);}
847 #line 250 "cursor.pgc"
848 
849 
850  strcpy(msg, "disconnect");
851  { ECPGdisconnect(__LINE__, "ALL");
852 #line 253 "cursor.pgc"
853 
854 if (sqlca.sqlcode < 0) exit (1);}
855 #line 253 "cursor.pgc"
856 
857 
858  return 0;
859 }
#define CURNAME
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:686
bool ECPGfetch(const char *cursor_name, const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: cursor.c:83
#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:2279
#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:228
void ECPGset_var(int number, void *pointer, int lineno)
Definition: misc.c:531
#define printf(...)
Definition: port.h:198
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
bool ECPGclose(const char *cursor_name, const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: cursor.c:125
bool ECPGopen(const char *cursor_name, const char *prepared_name, const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: cursor.c:28
bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
Definition: prepare.c:337
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:199
char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
Definition: prepare.c:401