| 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 "declare.pgc" |
| 10 |
#include <locale.h> |
| 11 |
#include <string.h> |
| 12 |
#include <stdlib.h> |
| 13 |
|
| 14 |
/* exec sql whenever sqlerror sqlprint ; */ |
| 15 |
#line 5 "declare.pgc" |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#line 1 "sqlca.h" |
| 20 |
#ifndef POSTGRES_SQLCA_H |
| 21 |
#define POSTGRES_SQLCA_H |
| 22 |
|
| 23 |
#ifndef PGDLLIMPORT |
| 24 |
#if defined(WIN32) || defined(__CYGWIN__) |
| 25 |
#define PGDLLIMPORT __declspec (dllimport) |
| 26 |
#else |
| 27 |
#define PGDLLIMPORT |
| 28 |
#endif /* __CYGWIN__ */ |
| 29 |
#endif /* PGDLLIMPORT */ |
| 30 |
|
| 31 |
#define SQLERRMC_LEN 150 |
| 32 |
|
| 33 |
#ifdef __cplusplus |
| 34 |
extern "C" |
| 35 |
{ |
| 36 |
#endif |
| 37 |
|
| 38 |
struct sqlca_t |
| 39 |
{ |
| 40 |
char sqlcaid[8]; |
| 41 |
long sqlabc; |
| 42 |
long sqlcode; |
| 43 |
struct |
| 44 |
{ |
| 45 |
int sqlerrml; |
| 46 |
char sqlerrmc[SQLERRMC_LEN]; |
| 47 |
} sqlerrm; |
| 48 |
char sqlerrp[8]; |
| 49 |
long sqlerrd[6]; |
| 50 |
/* Element 0: empty */ |
| 51 |
/* 1: OID of processed tuple if applicable */ |
| 52 |
/* 2: number of rows processed */ |
| 53 |
/* after an INSERT, UPDATE or */ |
| 54 |
/* DELETE statement */ |
| 55 |
/* 3: empty */ |
| 56 |
/* 4: empty */ |
| 57 |
/* 5: empty */ |
| 58 |
char sqlwarn[8]; |
| 59 |
/* Element 0: set to 'W' if at least one other is 'W' */ |
| 60 |
/* 1: if 'W' at least one character string */ |
| 61 |
/* value was truncated when it was */ |
| 62 |
/* stored into a host variable. */ |
| 63 |
|
| 64 |
/* |
| 65 |
* 2: if 'W' a (hopefully) non-fatal notice occurred |
| 66 |
*/ /* 3: empty */ |
| 67 |
/* 4: empty */ |
| 68 |
/* 5: empty */ |
| 69 |
/* 6: empty */ |
| 70 |
/* 7: empty */ |
| 71 |
|
| 72 |
char sqlstate[5]; |
| 73 |
}; |
| 74 |
|
| 75 |
struct sqlca_t *ECPGget_sqlca(void); |
| 76 |
|
| 77 |
#ifndef POSTGRES_ECPG_INTERNAL |
| 78 |
#define sqlca (*ECPGget_sqlca()) |
| 79 |
#endif |
| 80 |
|
| 81 |
#ifdef __cplusplus |
| 82 |
} |
| 83 |
#endif |
| 84 |
|
| 85 |
#endif |
| 86 |
|
| 87 |
#line 7 "declare.pgc" |
| 88 |
|
| 89 |
|
| 90 |
#line 1 "regression.h" |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
#line 8 "declare.pgc" |
| 98 |
|
| 99 |
|
| 100 |
#define ARRAY_SIZE 2 |
| 101 |
|
| 102 |
void execute_test(void); |
| 103 |
void commitTable(void); |
| 104 |
void reset(void); |
| 105 |
void printResult(char *tc_name, int loop); |
| 106 |
|
| 107 |
/* exec sql begin declare section */ |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
#line 18 "declare.pgc" |
| 113 |
int f1 [ ARRAY_SIZE ] ; |
| 114 |
|
| 115 |
#line 19 "declare.pgc" |
| 116 |
int f2 [ ARRAY_SIZE ] ; |
| 117 |
|
| 118 |
#line 20 "declare.pgc" |
| 119 |
char f3 [ ARRAY_SIZE ] [ 20 ] ; |
| 120 |
/* exec sql end declare section */ |
| 121 |
#line 21 "declare.pgc" |
| 122 |
|
| 123 |
|
| 124 |
int main(void) |
| 125 |
{ |
| 126 |
setlocale(LC_ALL, "C"); |
| 127 |
|
| 128 |
ECPGdebug(1, stderr); |
| 129 |
|
| 130 |
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con1", 0); |
| 131 |
#line 29 "declare.pgc" |
| 132 |
|
| 133 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 134 |
#line 29 "declare.pgc" |
| 135 |
|
| 136 |
{ ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "con2", 0); |
| 137 |
#line 30 "declare.pgc" |
| 138 |
|
| 139 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 140 |
#line 30 "declare.pgc" |
| 141 |
|
| 142 |
|
| 143 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT); |
| 144 |
#line 32 "declare.pgc" |
| 145 |
|
| 146 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 147 |
#line 32 "declare.pgc" |
| 148 |
|
| 149 |
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT); |
| 150 |
#line 33 "declare.pgc" |
| 151 |
|
| 152 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 153 |
#line 33 "declare.pgc" |
| 154 |
|
| 155 |
|
| 156 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT); |
| 157 |
#line 35 "declare.pgc" |
| 158 |
|
| 159 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 160 |
#line 35 "declare.pgc" |
| 161 |
|
| 162 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT); |
| 163 |
#line 36 "declare.pgc" |
| 164 |
|
| 165 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 166 |
#line 36 "declare.pgc" |
| 167 |
|
| 168 |
|
| 169 |
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT); |
| 170 |
#line 38 "declare.pgc" |
| 171 |
|
| 172 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 173 |
#line 38 "declare.pgc" |
| 174 |
|
| 175 |
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT); |
| 176 |
#line 39 "declare.pgc" |
| 177 |
|
| 178 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 179 |
#line 39 "declare.pgc" |
| 180 |
|
| 181 |
|
| 182 |
commitTable(); |
| 183 |
|
| 184 |
execute_test(); |
| 185 |
|
| 186 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT); |
| 187 |
#line 45 "declare.pgc" |
| 188 |
|
| 189 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 190 |
#line 45 "declare.pgc" |
| 191 |
|
| 192 |
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT); |
| 193 |
#line 46 "declare.pgc" |
| 194 |
|
| 195 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 196 |
#line 46 "declare.pgc" |
| 197 |
|
| 198 |
|
| 199 |
commitTable(); |
| 200 |
|
| 201 |
{ ECPGdisconnect(__LINE__, "ALL"); |
| 202 |
#line 50 "declare.pgc" |
| 203 |
|
| 204 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 205 |
#line 50 "declare.pgc" |
| 206 |
|
| 207 |
|
| 208 |
return 0; |
| 209 |
} |
| 210 |
|
| 211 |
/* |
| 212 |
* default connection: con2 |
| 213 |
* Non-default connection: con1 |
| 214 |
* |
| 215 |
*/ |
| 216 |
void execute_test(void) |
| 217 |
{ |
| 218 |
/* exec sql begin declare section */ |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
#line 63 "declare.pgc" |
| 223 |
int i , count , length ; |
| 224 |
|
| 225 |
#line 64 "declare.pgc" |
| 226 |
char * selectString = "SELECT f1,f2,f3 FROM source" ; |
| 227 |
/* exec sql end declare section */ |
| 228 |
#line 65 "declare.pgc" |
| 229 |
|
| 230 |
|
| 231 |
/* |
| 232 |
* testcase1. using DECLARE STATEMENT without using AT clause, |
| 233 |
* using PREPARE and CURSOR statement without using AT clause |
| 234 |
*/ |
| 235 |
reset(); |
| 236 |
|
| 237 |
/* declare \"stmt_1\" as an SQL identifier */ |
| 238 |
#line 73 "declare.pgc" |
| 239 |
|
| 240 |
{ ECPGprepare(__LINE__, NULL, 0, "stmt_1", selectString); |
| 241 |
#line 74 "declare.pgc" |
| 242 |
|
| 243 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 244 |
#line 74 "declare.pgc" |
| 245 |
|
| 246 |
/* declare cur_1 cursor for $1 */ |
| 247 |
#line 75 "declare.pgc" |
| 248 |
|
| 249 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_1 cursor for $1", |
| 250 |
ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), |
| 251 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); |
| 252 |
#line 76 "declare.pgc" |
| 253 |
|
| 254 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 255 |
#line 76 "declare.pgc" |
| 256 |
|
| 257 |
|
| 258 |
/* exec sql whenever not found break ; */ |
| 259 |
#line 78 "declare.pgc" |
| 260 |
|
| 261 |
i = 0; |
| 262 |
while (1) |
| 263 |
{ |
| 264 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_1", ECPGt_EOIT, |
| 265 |
ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), |
| 266 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 267 |
ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), |
| 268 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 269 |
ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), |
| 270 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 271 |
#line 82 "declare.pgc" |
| 272 |
|
| 273 |
if (sqlca.sqlcode == ECPG_NOT_FOUND) break; |
| 274 |
#line 82 "declare.pgc" |
| 275 |
|
| 276 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 277 |
#line 82 "declare.pgc" |
| 278 |
|
| 279 |
i++; |
| 280 |
} |
| 281 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_1", ECPGt_EOIT, ECPGt_EORT); |
| 282 |
#line 85 "declare.pgc" |
| 283 |
|
| 284 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 285 |
#line 85 "declare.pgc" |
| 286 |
|
| 287 |
{ ECPGdeallocate(__LINE__, 0, NULL, "stmt_1"); |
| 288 |
#line 86 "declare.pgc" |
| 289 |
|
| 290 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 291 |
#line 86 "declare.pgc" |
| 292 |
|
| 293 |
/* exec sql whenever not found continue ; */ |
| 294 |
#line 87 "declare.pgc" |
| 295 |
|
| 296 |
|
| 297 |
printResult("testcase1", 2); |
| 298 |
|
| 299 |
|
| 300 |
/* |
| 301 |
* testcase2. using DECLARE STATEMENT at con1, |
| 302 |
* using PREPARE and CURSOR statement without using AT clause |
| 303 |
*/ |
| 304 |
reset(); |
| 305 |
|
| 306 |
/* declare \"stmt_2\" as an SQL identifier */ |
| 307 |
#line 98 "declare.pgc" |
| 308 |
|
| 309 |
{ ECPGprepare(__LINE__, "con1", 0, "stmt_2", selectString); |
| 310 |
#line 99 "declare.pgc" |
| 311 |
|
| 312 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 313 |
#line 99 "declare.pgc" |
| 314 |
|
| 315 |
/* declare cur_2 cursor for $1 */ |
| 316 |
#line 100 "declare.pgc" |
| 317 |
|
| 318 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "declare cur_2 cursor for $1", |
| 319 |
ECPGt_char_variable,(ECPGprepared_statement("con1", "stmt_2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), |
| 320 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); |
| 321 |
#line 101 "declare.pgc" |
| 322 |
|
| 323 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 324 |
#line 101 "declare.pgc" |
| 325 |
|
| 326 |
|
| 327 |
/* exec sql whenever not found break ; */ |
| 328 |
#line 103 "declare.pgc" |
| 329 |
|
| 330 |
i = 0; |
| 331 |
while (1) |
| 332 |
{ |
| 333 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "fetch cur_2", ECPGt_EOIT, |
| 334 |
ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), |
| 335 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 336 |
ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), |
| 337 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 338 |
ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), |
| 339 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 340 |
#line 107 "declare.pgc" |
| 341 |
|
| 342 |
if (sqlca.sqlcode == ECPG_NOT_FOUND) break; |
| 343 |
#line 107 "declare.pgc" |
| 344 |
|
| 345 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 346 |
#line 107 "declare.pgc" |
| 347 |
|
| 348 |
i++; |
| 349 |
} |
| 350 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "close cur_2", ECPGt_EOIT, ECPGt_EORT); |
| 351 |
#line 110 "declare.pgc" |
| 352 |
|
| 353 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 354 |
#line 110 "declare.pgc" |
| 355 |
|
| 356 |
{ ECPGdeallocate(__LINE__, 0, "con1", "stmt_2"); |
| 357 |
#line 111 "declare.pgc" |
| 358 |
|
| 359 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 360 |
#line 111 "declare.pgc" |
| 361 |
|
| 362 |
/* exec sql whenever not found continue ; */ |
| 363 |
#line 112 "declare.pgc" |
| 364 |
|
| 365 |
|
| 366 |
printResult("testcase2", 2); |
| 367 |
|
| 368 |
/* |
| 369 |
* testcase3. using DECLARE STATEMENT without using AT clause, |
| 370 |
* using PREPARE and EXECUTE statement without using AT clause |
| 371 |
*/ |
| 372 |
reset(); |
| 373 |
|
| 374 |
/* declare \"stmt_3\" as an SQL identifier */ |
| 375 |
#line 122 "declare.pgc" |
| 376 |
|
| 377 |
{ ECPGprepare(__LINE__, NULL, 0, "stmt_3", selectString); |
| 378 |
#line 123 "declare.pgc" |
| 379 |
|
| 380 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 381 |
#line 123 "declare.pgc" |
| 382 |
|
| 383 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_3", ECPGt_EOIT, |
| 384 |
ECPGt_int,(f1),(long)1,(long)ARRAY_SIZE,sizeof(int), |
| 385 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 386 |
ECPGt_int,(f2),(long)1,(long)ARRAY_SIZE,sizeof(int), |
| 387 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 388 |
ECPGt_char,(f3),(long)20,(long)ARRAY_SIZE,(20)*sizeof(char), |
| 389 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 390 |
#line 124 "declare.pgc" |
| 391 |
|
| 392 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 393 |
#line 124 "declare.pgc" |
| 394 |
|
| 395 |
|
| 396 |
{ ECPGdeallocate(__LINE__, 0, NULL, "stmt_3"); |
| 397 |
#line 126 "declare.pgc" |
| 398 |
|
| 399 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 400 |
#line 126 "declare.pgc" |
| 401 |
|
| 402 |
|
| 403 |
printResult("testcase3", 2); |
| 404 |
|
| 405 |
/* |
| 406 |
* testcase4. using DECLARE STATEMENT without using AT clause, |
| 407 |
* using PREPARE and CURSOR statement at con2 |
| 408 |
*/ |
| 409 |
reset(); |
| 410 |
|
| 411 |
/* declare \"stmt_4\" as an SQL identifier */ |
| 412 |
#line 136 "declare.pgc" |
| 413 |
|
| 414 |
{ ECPGprepare(__LINE__, "con2", 0, "stmt_4", selectString); |
| 415 |
#line 137 "declare.pgc" |
| 416 |
|
| 417 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 418 |
#line 137 "declare.pgc" |
| 419 |
|
| 420 |
/* declare cur_4 cursor for $1 */ |
| 421 |
#line 138 "declare.pgc" |
| 422 |
|
| 423 |
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_4 cursor for $1", |
| 424 |
ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_4", __LINE__)),(long)1,(long)1,(1)*sizeof(char), |
| 425 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); |
| 426 |
#line 139 "declare.pgc" |
| 427 |
|
| 428 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 429 |
#line 139 "declare.pgc" |
| 430 |
|
| 431 |
|
| 432 |
/* exec sql whenever not found break ; */ |
| 433 |
#line 141 "declare.pgc" |
| 434 |
|
| 435 |
i = 0; |
| 436 |
while (1) |
| 437 |
{ |
| 438 |
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch cur_4", ECPGt_EOIT, |
| 439 |
ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), |
| 440 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 441 |
ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), |
| 442 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 443 |
ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), |
| 444 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 445 |
#line 145 "declare.pgc" |
| 446 |
|
| 447 |
if (sqlca.sqlcode == ECPG_NOT_FOUND) break; |
| 448 |
#line 145 "declare.pgc" |
| 449 |
|
| 450 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 451 |
#line 145 "declare.pgc" |
| 452 |
|
| 453 |
i++; |
| 454 |
} |
| 455 |
{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_4", ECPGt_EOIT, ECPGt_EORT); |
| 456 |
#line 148 "declare.pgc" |
| 457 |
|
| 458 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 459 |
#line 148 "declare.pgc" |
| 460 |
|
| 461 |
{ ECPGdeallocate(__LINE__, 0, "con2", "stmt_4"); |
| 462 |
#line 149 "declare.pgc" |
| 463 |
|
| 464 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 465 |
#line 149 "declare.pgc" |
| 466 |
|
| 467 |
/* exec sql whenever not found continue ; */ |
| 468 |
#line 150 "declare.pgc" |
| 469 |
|
| 470 |
|
| 471 |
printResult("testcase4", 2); |
| 472 |
|
| 473 |
/* |
| 474 |
* DESCRIBE statement is also supported. |
| 475 |
*/ |
| 476 |
/* declare \"stmt_desc\" as an SQL identifier */ |
| 477 |
#line 157 "declare.pgc" |
| 478 |
|
| 479 |
{ ECPGprepare(__LINE__, "con1", 0, "stmt_desc", selectString); |
| 480 |
#line 158 "declare.pgc" |
| 481 |
|
| 482 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 483 |
#line 158 "declare.pgc" |
| 484 |
|
| 485 |
/* declare cur_desc cursor for $1 */ |
| 486 |
#line 159 "declare.pgc" |
| 487 |
|
| 488 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "declare cur_desc cursor for $1", |
| 489 |
ECPGt_char_variable,(ECPGprepared_statement("con1", "stmt_desc", __LINE__)),(long)1,(long)1,(1)*sizeof(char), |
| 490 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); |
| 491 |
#line 160 "declare.pgc" |
| 492 |
|
| 493 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 494 |
#line 160 "declare.pgc" |
| 495 |
|
| 496 |
|
| 497 |
/* descriptor can be used for describe statement */ |
| 498 |
ECPGallocate_desc(__LINE__, "desc_for_describe"); |
| 499 |
#line 163 "declare.pgc" |
| 500 |
|
| 501 |
if (sqlca.sqlcode < 0) sqlprint(); |
| 502 |
#line 163 "declare.pgc" |
| 503 |
|
| 504 |
{ ECPGdescribe(__LINE__, 0, 0, "con1", "stmt_desc", |
| 505 |
ECPGt_descriptor, "desc_for_describe", 1L, 1L, 1L, |
| 506 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} |
| 507 |
#line 164 "declare.pgc" |
| 508 |
|
| 509 |
|
| 510 |
{ ECPGget_desc_header(__LINE__, "desc_for_describe", &(count)); |
| 511 |
|
| 512 |
#line 166 "declare.pgc" |
| 513 |
|
| 514 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 515 |
#line 166 "declare.pgc" |
| 516 |
|
| 517 |
{ ECPGget_desc(__LINE__, "desc_for_describe", 3,ECPGd_length, |
| 518 |
ECPGt_int,&(length),(long)1,(long)1,sizeof(int), ECPGd_EODT); |
| 519 |
|
| 520 |
#line 167 "declare.pgc" |
| 521 |
|
| 522 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 523 |
#line 167 "declare.pgc" |
| 524 |
|
| 525 |
|
| 526 |
ECPGdeallocate_desc(__LINE__, "desc_for_describe"); |
| 527 |
#line 169 "declare.pgc" |
| 528 |
|
| 529 |
if (sqlca.sqlcode < 0) sqlprint(); |
| 530 |
#line 169 "declare.pgc" |
| 531 |
|
| 532 |
|
| 533 |
/* for fetch statement */ |
| 534 |
ECPGallocate_desc(__LINE__, "desc_for_fetch"); |
| 535 |
#line 172 "declare.pgc" |
| 536 |
|
| 537 |
if (sqlca.sqlcode < 0) sqlprint(); |
| 538 |
#line 172 "declare.pgc" |
| 539 |
|
| 540 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "fetch cur_desc", ECPGt_EOIT, |
| 541 |
ECPGt_descriptor, "desc_for_fetch", 1L, 1L, 1L, |
| 542 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 543 |
#line 173 "declare.pgc" |
| 544 |
|
| 545 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 546 |
#line 173 "declare.pgc" |
| 547 |
|
| 548 |
|
| 549 |
{ ECPGget_desc(__LINE__, "desc_for_fetch", 3,ECPGd_data, |
| 550 |
ECPGt_char,(f3[0]),(long)20,(long)1,(20)*sizeof(char), ECPGd_EODT); |
| 551 |
|
| 552 |
#line 175 "declare.pgc" |
| 553 |
|
| 554 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 555 |
#line 175 "declare.pgc" |
| 556 |
|
| 557 |
|
| 558 |
ECPGdeallocate_desc(__LINE__, "desc_for_fetch"); |
| 559 |
#line 177 "declare.pgc" |
| 560 |
|
| 561 |
if (sqlca.sqlcode < 0) sqlprint(); |
| 562 |
#line 177 "declare.pgc" |
| 563 |
|
| 564 |
{ ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "close cur_desc", ECPGt_EOIT, ECPGt_EORT); |
| 565 |
#line 178 "declare.pgc" |
| 566 |
|
| 567 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 568 |
#line 178 "declare.pgc" |
| 569 |
|
| 570 |
{ ECPGdeallocate(__LINE__, 0, "con1", "stmt_desc"); |
| 571 |
#line 179 "declare.pgc" |
| 572 |
|
| 573 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 574 |
#line 179 "declare.pgc" |
| 575 |
|
| 576 |
|
| 577 |
printf("****descriptor results****\n"); |
| 578 |
printf("count: %d, length: %d, data: %s\n", count, length, f3[0]); |
| 579 |
} |
| 580 |
|
| 581 |
void commitTable() |
| 582 |
{ |
| 583 |
{ ECPGtrans(__LINE__, "con1", "commit"); |
| 584 |
#line 187 "declare.pgc" |
| 585 |
|
| 586 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 587 |
#line 187 "declare.pgc" |
| 588 |
|
| 589 |
{ ECPGtrans(__LINE__, "con2", "commit"); |
| 590 |
#line 188 "declare.pgc" |
| 591 |
|
| 592 |
if (sqlca.sqlcode < 0) sqlprint();} |
| 593 |
#line 188 "declare.pgc" |
| 594 |
|
| 595 |
} |
| 596 |
|
| 597 |
/* |
| 598 |
* reset all the output variables |
| 599 |
*/ |
| 600 |
void reset() |
| 601 |
{ |
| 602 |
memset(f1, 0, sizeof(f1)); |
| 603 |
memset(f2, 0, sizeof(f2)); |
| 604 |
memset(f3, 0, sizeof(f3)); |
| 605 |
} |
| 606 |
|
| 607 |
void printResult(char *tc_name, int loop) |
| 608 |
{ |
| 609 |
int i; |
| 610 |
|
| 611 |
if (tc_name) |
| 612 |
printf("****%s test results:****\n", tc_name); |
| 613 |
|
| 614 |
for (i = 0; i < loop; i++) |
| 615 |
printf("f1=%d, f2=%d, f3=%s\n", f1[i], f2[i], f3[i]); |
| 616 |
|
| 617 |
printf("\n"); |
| 618 |
} |