PostgreSQL Source Code git master
preproc-whenever_do_continue.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 "whenever_do_continue.pgc"
10#include <stdlib.h>
11
12
13#line 1 "regression.h"
14
15
16
17
18
19
20#line 3 "whenever_do_continue.pgc"
21
22
23/* exec sql whenever sqlerror stop ; */
24#line 5 "whenever_do_continue.pgc"
25
26
27int main(void)
28{
29 /* exec sql begin declare section */
30
31
32
33
34
35
36
37
38
39#line 15 "whenever_do_continue.pgc"
40 struct {
41#line 12 "whenever_do_continue.pgc"
42 char ename [ 12 ] ;
43
44#line 13 "whenever_do_continue.pgc"
45 float sal ;
46
47#line 14 "whenever_do_continue.pgc"
48 float comm ;
49 } emp ;
50
51#line 16 "whenever_do_continue.pgc"
52 int loopcount ;
53
54#line 17 "whenever_do_continue.pgc"
55 char msg [ 128 ] ;
56/* exec sql end declare section */
57#line 18 "whenever_do_continue.pgc"
58
59
60 ECPGdebug(1, stderr);
61
62 strcpy(msg, "connect");
63 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
64#line 23 "whenever_do_continue.pgc"
65
66if (sqlca.sqlcode < 0) exit (1);}
67#line 23 "whenever_do_continue.pgc"
68
69
70 strcpy(msg, "create");
71 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table emp ( ename varchar , sal double precision , comm double precision )", ECPGt_EOIT, ECPGt_EORT);
72#line 26 "whenever_do_continue.pgc"
73
74if (sqlca.sqlcode < 0) exit (1);}
75#line 26 "whenever_do_continue.pgc"
76
77
78 strcpy(msg, "insert");
79 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'Ram' , 111100 , 21 )", ECPGt_EOIT, ECPGt_EORT);
80#line 29 "whenever_do_continue.pgc"
81
82if (sqlca.sqlcode < 0) exit (1);}
83#line 29 "whenever_do_continue.pgc"
84
85 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'aryan' , 11110 , null )", ECPGt_EOIT, ECPGt_EORT);
86#line 30 "whenever_do_continue.pgc"
87
88if (sqlca.sqlcode < 0) exit (1);}
89#line 30 "whenever_do_continue.pgc"
90
91 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'josh' , 10000 , 10 )", ECPGt_EOIT, ECPGt_EORT);
92#line 31 "whenever_do_continue.pgc"
93
94if (sqlca.sqlcode < 0) exit (1);}
95#line 31 "whenever_do_continue.pgc"
96
97 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'tom' , 20000 , null )", ECPGt_EOIT, ECPGt_EORT);
98#line 32 "whenever_do_continue.pgc"
99
100if (sqlca.sqlcode < 0) exit (1);}
101#line 32 "whenever_do_continue.pgc"
102
103
104 /* declare c cursor for select ename , sal , comm from emp order by ename collate \"C\" asc */
105#line 34 "whenever_do_continue.pgc"
106
107
108 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c cursor for select ename , sal , comm from emp order by ename collate \"C\" asc", ECPGt_EOIT, ECPGt_EORT);
109#line 36 "whenever_do_continue.pgc"
110
111if (sqlca.sqlcode < 0) exit (1);}
112#line 36 "whenever_do_continue.pgc"
113
114
115 /* The 'BREAK' condition to exit the loop. */
116 /* exec sql whenever not found break ; */
117#line 39 "whenever_do_continue.pgc"
118
119
120 /* The DO CONTINUE makes the loop start at the next iteration when an error occurs.*/
121 /* exec sql whenever sqlerror continue ; */
122#line 42 "whenever_do_continue.pgc"
123
124
125 for (loopcount = 0; loopcount < 100; loopcount++)
126 {
127 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch c", ECPGt_EOIT,
128 ECPGt_char,&(emp.ename),(long)12,(long)1,(12)*sizeof(char),
129 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
130 ECPGt_float,&(emp.sal),(long)1,(long)1,sizeof(float),
131 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
132 ECPGt_float,&(emp.comm),(long)1,(long)1,sizeof(float),
133 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
134#line 46 "whenever_do_continue.pgc"
135
136if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
137#line 46 "whenever_do_continue.pgc"
138
139if (sqlca.sqlcode < 0) continue;}
140#line 46 "whenever_do_continue.pgc"
141
142 /* The employees with non-NULL commissions will be displayed. */
143 printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
144 }
145
146 /*
147 * This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
148 * proceed if any further errors do occur.
149 */
150 /* exec sql whenever sqlerror continue ; */
151#line 55 "whenever_do_continue.pgc"
152
153
154 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c", ECPGt_EOIT, ECPGt_EORT);}
155#line 57 "whenever_do_continue.pgc"
156
157
158 strcpy(msg, "drop");
159 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table emp", ECPGt_EOIT, ECPGt_EORT);}
160#line 60 "whenever_do_continue.pgc"
161
162
163 exit(0);
164}
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:255
#define ECPG_NOT_FOUND
Definition: ecpgerrno.h:10
@ ECPGst_normal
Definition: ecpgtype.h:97
@ ECPGt_float
Definition: ecpgtype.h:47
@ ECPGt_EOIT
Definition: ecpgtype.h:62
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_EORT
Definition: ecpgtype.h:63
@ ECPGt_char
Definition: ecpgtype.h:43
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:2275
exit(1)
#define printf(...)
Definition: port.h:245
int main(void)
#define ECPGdebug(X, Y)
#define sqlca
Definition: sqlca.h:59