32{
33
34
35
36
37
38
39
40#line 14 "execute.pgc"
41 int amount [ 8 ] ;
42
43#line 15 "execute.pgc"
44 int increment = 100 ;
45
46#line 16 "execute.pgc"
47 char name [ 8 ] [ 8 ] ;
48
49#line 17 "execute.pgc"
50 char letter [ 8 ] [ 1 ] ;
51
52#line 18 "execute.pgc"
53 char command [ 128 ] ;
54
55#line 19 "execute.pgc"
56
58
60
61 {
ECPGconnect(__LINE__, 0,
"ecpg1_regression" , NULL, NULL ,
"main", 0);
62#line 24 "execute.pgc"
63
65#line 24 "execute.pgc"
66
67 {
ECPGdo(__LINE__, 0, 1, NULL, 0,
ECPGst_normal,
"create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )",
ECPGt_EOIT,
ECPGt_EORT);
68#line 25 "execute.pgc"
69
71#line 25 "execute.pgc"
72
74#line 26 "execute.pgc"
75
77#line 26 "execute.pgc"
78
79
80
81 {
ECPGdo(__LINE__, 0, 1, NULL, 0,
ECPGst_exec_immediate,
"insert into test (name, \042amount\042, letter) values ('db: ''r1''', 1, 'f')",
ECPGt_EOIT,
ECPGt_EORT);
82#line 29 "execute.pgc"
83
85#line 29 "execute.pgc"
86
87
88 sprintf(command,
"insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
90#line 32 "execute.pgc"
91
93#line 32 "execute.pgc"
94
95
96 sprintf(command,
"insert into test (name, amount, letter) select name, amount+10, letter from test");
98#line 35 "execute.pgc"
99
101#line 35 "execute.pgc"
102
103
104 printf(
"Inserted %ld tuples via execute immediate\n",
sqlca.sqlerrd[2]);
105
106 sprintf(command,
"insert into test (name, amount, letter) select name, amount+$1, letter from test");
108#line 40 "execute.pgc"
109
111#line 40 "execute.pgc"
112
114 ECPGt_int,&(increment),(
long)1,(
long)1,
sizeof(
int),
116#line 41 "execute.pgc"
117
119#line 41 "execute.pgc"
120
121
122 printf(
"Inserted %ld tuples via prepared execute\n",
sqlca.sqlerrd[2]);
123
125#line 45 "execute.pgc"
126
128#line 45 "execute.pgc"
129
130
131 sprintf (command,
"select * from test");
132
134#line 49 "execute.pgc"
135
137#line 49 "execute.pgc"
138
139
140#line 50 "execute.pgc"
141
142
146#line 52 "execute.pgc"
147
149#line 52 "execute.pgc"
150
154 ECPGt_int,(amount),(
long)1,(
long)8,
sizeof(
int),
156 ECPGt_char,(letter),(
long)1,(
long)8,(1)*
sizeof(
char),
158#line 53 "execute.pgc"
159
161#line 53 "execute.pgc"
162
163
165 {
166
167
168
169
170#line 58 "execute.pgc"
171 char n [ 8 ] , l = letter [
i ] [ 0 ] ;
172
173#line 59 "execute.pgc"
174 int a = amount [
i ] ;
175
176#line 60 "execute.pgc"
177
178
179 strncpy(n,
name[
i], 8);
180 printf(
"name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n",
i, n,
i,
a,
i, l);
181 }
182
184#line 66 "execute.pgc"
185
187#line 66 "execute.pgc"
188
190#line 67 "execute.pgc"
191
193#line 67 "execute.pgc"
194
195
196 sprintf (command,
"select * from test where amount = $1");
197
199#line 71 "execute.pgc"
200
202#line 71 "execute.pgc"
203
204
205#line 72 "execute.pgc"
206
207
213#line 74 "execute.pgc"
214
216#line 74 "execute.pgc"
217
221 ECPGt_int,(amount),(
long)1,(
long)8,
sizeof(
int),
223 ECPGt_char,(letter),(
long)1,(
long)8,(1)*
sizeof(
char),
225#line 75 "execute.pgc"
226
228#line 75 "execute.pgc"
229
230
232 {
233
234
235
236
237#line 80 "execute.pgc"
238 char n [ 8 ] , l = letter [
i ] [ 0 ] ;
239
240#line 81 "execute.pgc"
241 int a = amount [
i ] ;
242
243#line 82 "execute.pgc"
244
245
246 strncpy(n,
name[
i], 8);
247 printf(
"name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n",
i, n,
i,
a,
i, l);
248 }
249
251#line 88 "execute.pgc"
252
254#line 88 "execute.pgc"
255
257#line 89 "execute.pgc"
258
260#line 89 "execute.pgc"
261
262
263 sprintf (command,
"select * from test where amount = $1");
264
266#line 93 "execute.pgc"
267
269#line 93 "execute.pgc"
270
276 ECPGt_int,(amount),(
long)1,(
long)8,
sizeof(
int),
278 ECPGt_char,(letter),(
long)1,(
long)8,(1)*
sizeof(
char),
280#line 94 "execute.pgc"
281
283#line 94 "execute.pgc"
284
285
287 {
288
289
290
291
292#line 99 "execute.pgc"
293 char n [ 8 ] , l = letter [
i ] [ 0 ] ;
294
295#line 100 "execute.pgc"
296 int a = amount [
i ] ;
297
298#line 101 "execute.pgc"
299
300
301 strncpy(n,
name[
i], 8);
302 printf(
"name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n",
i, n,
i,
a,
i, l);
303 }
304
306#line 107 "execute.pgc"
307
309#line 107 "execute.pgc"
310
312#line 108 "execute.pgc"
313
315#line 108 "execute.pgc"
316
318#line 109 "execute.pgc"
319
321#line 109 "execute.pgc"
322
324#line 110 "execute.pgc"
325
327#line 110 "execute.pgc"
328
329
330 return 0;
331}
bool ECPGdisconnect(int lineno, const char *connection_name)
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
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,...)
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)