int main () { int i; #ifdef WIN32 HANDLE threads[THREADS]; #else pthread_t threads[THREADS]; #endif { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 69 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 69 "prep.pgc" { ECPGsetcommit(__LINE__, "on", NULL); #line 70 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 70 "prep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table if exists T", ECPGt_EOIT, ECPGt_EORT); #line 71 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 71 "prep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( i int )", ECPGt_EOIT, ECPGt_EORT); #line 72 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 72 "prep.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 73 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 73 "prep.pgc" #ifdef WIN32 for (i = 0; i < THREADS; ++i) { unsigned id; threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id); } WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE); for (i = 0; i < THREADS; ++i) CloseHandle(threads[i]); #else for (i = 0; i < THREADS; ++i) pthread_create(&threads[i], NULL, fn, (void *) (long) i); for (i = 0; i < THREADS; ++i) pthread_join(threads[i], NULL); #endif return 0; }
void commitTable() { { ECPGtrans(__LINE__, "con1", "commit"); #line 182 "declare.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 182 "declare.pgc" { ECPGtrans(__LINE__, "con2", "commit"); #line 183 "declare.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 183 "declare.pgc" }
int main (int argc, char *argv[]) { int items; int i, r; if (argc != 2) { fprintf(stderr,"Usage: %s <items>\n",argv[0]); exit (1); } items = atoi(argv[1]); if (items < 2) { fprintf(stderr,"too small\n"); exit (1); } srand((unsigned) time(NULL)); for (i = 1; i < items; i++) { // we don't want to stick the rand() call into the sqlprint macro, just in case we want to use it multiple times r = rand() % i; sqlprint(r,i); } exit (0); }/*main()*/
neo_main() { int fd; int ret; int i; int m; r_expr_t *np, *nnp; char *wcp; char wbuf[256]; char sql[256]; extern int sqldebug; sqldebug = 1; sql_lex_init(); /***** for( i = 0; i < sizeof(sql)/sizeof(sql[0]); i++ ) { ******/ for( i = 0; i < 10; i++ ) { printf("sql>"); wcp = gets(wbuf); if( wcp == 0 ) { printf("\n Read Error\n"); break; } printf("\nINPUT:%s\n", wbuf); sql[0] = '\0'; strcpy(sql,wbuf); printf("**** INPUT: HEX DUMP ***\n"); for(m=0;m<256;m++) { if( sql[m] == '\0' ) break; printf("%c(%0x) ",sql[m],sql[m]); } printf("\n**** HEX DUMP ***\n"); sql_mem_init(); /*** sql_lex_start( sql[i], buff, sizeof(buff) ); ***/ sql_lex_start( sql, buff, sizeof(buff) ); ret = sqlparse(); /*** printf("%d:sqlparse=%d[%s]\n", i, ret, sql[i] ); ***/ printf("%d:sqlparse=%d[%s]\n", i, ret, sql ); if( ret ) break; sqlprint( SQLreturn, 0 ); sql_free( SQLreturn ); } }
static void* fn(void* arg) #endif { int i; for (i = 1; i <= REPEATS; ++i) { ECPGallocate_desc(__LINE__, "mydesc"); #line 29 "descriptor.pgc" if (sqlca.sqlcode < 0) sqlprint(); #line 29 "descriptor.pgc" ECPGdeallocate_desc(__LINE__, "mydesc"); #line 30 "descriptor.pgc" if (sqlca.sqlcode < 0) sqlprint(); #line 30 "descriptor.pgc" } return 0; }
int main(void) { /* exec sql begin declare section */ #line 8 "desc.pgc" char * stmt1 = "INSERT INTO test1 VALUES ($1, $2)" ; #line 9 "desc.pgc" char * stmt2 = "SELECT * from test1 where a = $1 and b = $2" ; #line 10 "desc.pgc" char * stmt3 = "SELECT * from test1 where :var = a" ; #line 12 "desc.pgc" int val1 = 1 ; #line 13 "desc.pgc" char val2 [ 4 ] = "one" , val2output [] = "AAA" ; #line 14 "desc.pgc" int val1output = 2 , val2i = 0 ; #line 15 "desc.pgc" int val2null = - 1 ; #line 16 "desc.pgc" int ind1 , ind2 ; #line 17 "desc.pgc" char desc1 [ 8 ] = "outdesc" ; /* exec sql end declare section */ #line 18 "desc.pgc" ECPGdebug(1, stderr); ECPGallocate_desc(__LINE__, "indesc"); #line 22 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint(); #line 22 "desc.pgc" ECPGallocate_desc(__LINE__, (desc1)); #line 23 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint(); #line 23 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT); #line 25 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 25 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator, ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT); #line 26 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 26 "desc.pgc" { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 28 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 28 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test1 ( a int , b text )", ECPGt_EOIT, ECPGt_EORT); #line 30 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 30 "desc.pgc" { ECPGprepare(__LINE__, NULL, 0, "foo1", stmt1); #line 31 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 31 "desc.pgc" { ECPGprepare(__LINE__, NULL, 0, "Foo-1", stmt1); #line 32 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 32 "desc.pgc" { ECPGprepare(__LINE__, NULL, 0, "foo2", stmt2); #line 33 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 33 "desc.pgc" { ECPGprepare(__LINE__, NULL, 0, "foo3", stmt3); #line 34 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 34 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo1", ECPGt_descriptor, "indesc", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 36 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 36 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT); #line 38 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 38 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator, ECPGt_int,&(val2null),(long)1,(long)1,sizeof(int), ECPGd_EODT); #line 39 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 39 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo1", ECPGt_descriptor, "indesc", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 41 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 41 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, ECPGt_const,"3",(long)1,(long)1,strlen("3"), ECPGd_EODT); #line 43 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 43 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, ECPGt_const,"this is a long test",(long)19,(long)1,strlen("this is a long test"), ECPGd_indicator, ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT); #line 44 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 44 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "Foo-1", ECPGt_descriptor, "indesc", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 46 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 46 "desc.pgc" { ECPGdeallocate(__LINE__, 0, NULL, "Foo-1"); #line 48 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 48 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT); #line 50 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 50 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator, ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT); #line 51 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 51 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo2", ECPGt_descriptor, "indesc", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_descriptor, "outdesc", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 53 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 53 "desc.pgc" { ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data, ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT); #line 55 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 55 "desc.pgc" printf("output = %s\n", val2output); /* declare c1 cursor for $1 */ #line 58 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c1 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_descriptor, "indesc", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 59 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 59 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c1", ECPGt_EOIT, ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT); #line 61 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 61 "desc.pgc" printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n", val1output, ind1, val2output, ind2); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c1", ECPGt_EOIT, ECPGt_EORT); #line 65 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 65 "desc.pgc" { ECPGset_desc_header(__LINE__, "indesc", (int)(1)); #line 67 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 67 "desc.pgc" { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT); #line 68 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 68 "desc.pgc" /* declare c2 cursor for $1 */ #line 70 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c2 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo3", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_descriptor, "indesc", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 71 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 71 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c2", ECPGt_EOIT, ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT); #line 73 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 73 "desc.pgc" printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c2", ECPGt_EOIT, ECPGt_EORT); #line 76 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 76 "desc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test1 where a = 3", ECPGt_EOIT, ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT); #line 78 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 78 "desc.pgc" printf("val1=%d val2=%c%c%c%c warn=%c truncate=%d\n", val1output, val2output[0], val2output[1], val2output[2], val2output[3], sqlca.sqlwarn[0], val2i); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test1", ECPGt_EOIT, ECPGt_EORT); #line 81 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 81 "desc.pgc" { ECPGdeallocate_all(__LINE__, 0, NULL); #line 82 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 82 "desc.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 83 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 83 "desc.pgc" ECPGdeallocate_desc(__LINE__, "indesc"); #line 85 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint(); #line 85 "desc.pgc" ECPGdeallocate_desc(__LINE__, "outdesc"); #line 86 "desc.pgc" if (sqlca.sqlcode < 0) sqlprint(); #line 86 "desc.pgc" return 0; }
static void print(char *msg) { fprintf(stderr, "Error in statement '%s':\n", msg); sqlprint(); }
int main() { /* exec sql begin declare section */ #line 9 "show.pgc" char var [ 25 ] = "public" ; /* exec sql end declare section */ #line 10 "show.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } #line 13 "show.pgc" /* exec sql whenever sql_warning sqlprint ; */ #line 15 "show.pgc" /* exec sql whenever sqlerror sqlprint ; */ #line 16 "show.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set search_path to $0", ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 18 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 18 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 18 "show.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show search_path", ECPGt_EOIT, ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 19 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 19 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 19 "show.pgc" printf("Var: Search path: %s\n", var); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set search_path to 'public'", ECPGt_EOIT, ECPGt_EORT); #line 22 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 22 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 22 "show.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show search_path", ECPGt_EOIT, ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 23 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 23 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 23 "show.pgc" printf("Var: Search path: %s\n", var); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT); #line 26 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 26 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 26 "show.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT, ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 27 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 27 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 27 "show.pgc" printf("Var: Standard conforming strings: %s\n", var); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set time zone PST8PDT", ECPGt_EOIT, ECPGt_EORT); #line 30 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 30 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 30 "show.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show time zone", ECPGt_EOIT, ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 31 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 31 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 31 "show.pgc" printf("Time Zone: %s\n", var); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set transaction isolation level read committed", ECPGt_EOIT, ECPGt_EORT); #line 34 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 34 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 34 "show.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show transaction isolation level", ECPGt_EOIT, ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 35 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 35 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 35 "show.pgc" printf("Transaction isolation level: %s\n", var); { ECPGdisconnect(__LINE__, "ALL"); #line 38 "show.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 38 "show.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 38 "show.pgc" return 0; }
int main(void) { /* exec sql begin declare section */ #line 15 "whenever_do_continue.pgc" struct { #line 12 "whenever_do_continue.pgc" char ename [ 12 ] ; #line 13 "whenever_do_continue.pgc" float sal ; #line 14 "whenever_do_continue.pgc" float comm ; } emp ; #line 17 "whenever_do_continue.pgc" char msg [ 128 ] ; /* exec sql end declare section */ #line 18 "whenever_do_continue.pgc" ECPGdebug(1, stderr); strcpy(msg, "connect"); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); #line 23 "whenever_do_continue.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 23 "whenever_do_continue.pgc" strcpy(msg, "create"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table emp ( ename varchar , sal double precision , comm double precision )", ECPGt_EOIT, ECPGt_EORT); #line 26 "whenever_do_continue.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 26 "whenever_do_continue.pgc" strcpy(msg, "insert"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'Ram' , 111100 , 21 )", ECPGt_EOIT, ECPGt_EORT); #line 29 "whenever_do_continue.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 29 "whenever_do_continue.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'aryan' , 11110 , null )", ECPGt_EOIT, ECPGt_EORT); #line 30 "whenever_do_continue.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 30 "whenever_do_continue.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'josh' , 10000 , 10 )", ECPGt_EOIT, ECPGt_EORT); #line 31 "whenever_do_continue.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 31 "whenever_do_continue.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'tom' , 20000 , null )", ECPGt_EOIT, ECPGt_EORT); #line 32 "whenever_do_continue.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 32 "whenever_do_continue.pgc" /* declare c cursor for select ename , sal , comm from emp order by ename collate \"C\" asc */ #line 34 "whenever_do_continue.pgc" { 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); #line 36 "whenever_do_continue.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 36 "whenever_do_continue.pgc" /* The 'BREAK' condition to exit the loop. */ /* exec sql whenever not found break ; */ #line 39 "whenever_do_continue.pgc" /* The DO CONTINUE makes the loop start at the next iteration when an error occurs.*/ /* exec sql whenever sqlerror continue ; */ #line 42 "whenever_do_continue.pgc" while (1) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch c", ECPGt_EOIT, ECPGt_char,&(emp.ename),(long)12,(long)1,(12)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_float,&(emp.sal),(long)1,(long)1,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_float,&(emp.comm),(long)1,(long)1,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 46 "whenever_do_continue.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 46 "whenever_do_continue.pgc" if (sqlca.sqlcode < 0) continue;} #line 46 "whenever_do_continue.pgc" /* The employees with non-NULL commissions will be displayed. */ printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm); } /* * This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to * proceed if any further errors do occur. */ /* exec sql whenever sqlerror continue ; */ #line 55 "whenever_do_continue.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c", ECPGt_EOIT, ECPGt_EORT);} #line 57 "whenever_do_continue.pgc" strcpy(msg, "drop"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table emp", ECPGt_EOIT, ECPGt_EORT);} #line 60 "whenever_do_continue.pgc" exit(0); }
int main(void) { /* exec sql begin declare section */ #line 14 "execute.pgc" int amount [ 8 ] ; #line 15 "execute.pgc" int increment = 100 ; #line 16 "execute.pgc" char name [ 8 ] [ 8 ] ; #line 17 "execute.pgc" char letter [ 8 ] [ 1 ] ; #line 18 "execute.pgc" char command [ 128 ] ; /* exec sql end declare section */ #line 19 "execute.pgc" int i,j; ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "main", 0); #line 24 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 24 "execute.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )", ECPGt_EOIT, ECPGt_EORT); #line 25 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 25 "execute.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 26 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 26 "execute.pgc" sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')"); { ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT); #line 29 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 29 "execute.pgc" sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')"); { ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT); #line 32 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 32 "execute.pgc" sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test"); { ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT); #line 35 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 35 "execute.pgc" printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]); sprintf(command, "insert into test (name, amount, letter) select name, amount+$1, letter from test"); { ECPGprepare(__LINE__, NULL, 0, "i", command); #line 40 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 40 "execute.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "i", ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 41 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 41 "execute.pgc" printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]); { ECPGtrans(__LINE__, NULL, "commit"); #line 45 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 45 "execute.pgc" sprintf (command, "select * from test"); { ECPGprepare(__LINE__, NULL, 0, "f", command); #line 49 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 49 "execute.pgc" /* declare CUR cursor for $1 */ #line 50 "execute.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 52 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 52 "execute.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 53 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 53 "execute.pgc" for (i=0, j=sqlca.sqlerrd[2]; i<j; i++) { /* exec sql begin declare section */ #line 58 "execute.pgc" char n [ 8 ] , l = letter [ i ] [ 0 ] ; #line 59 "execute.pgc" int a = amount [ i ] ; /* exec sql end declare section */ #line 60 "execute.pgc" strncpy(n, name[i], 8); printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT); #line 66 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 66 "execute.pgc" { ECPGdeallocate(__LINE__, 0, NULL, "f"); #line 67 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 67 "execute.pgc" sprintf (command, "select * from test where amount = $1"); { ECPGprepare(__LINE__, NULL, 0, "f", command); #line 71 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 71 "execute.pgc" /* declare CUR2 cursor for $1 */ #line 72 "execute.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR2 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_const,"1",(long)1,(long)1,strlen("1"), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 74 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 74 "execute.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch in CUR2", ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 75 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 75 "execute.pgc" for (i=0, j=sqlca.sqlerrd[2]; i<j; i++) { /* exec sql begin declare section */ #line 80 "execute.pgc" char n [ 8 ] , l = letter [ i ] [ 0 ] ; #line 81 "execute.pgc" int a = amount [ i ] ; /* exec sql end declare section */ #line 82 "execute.pgc" strncpy(n, name[i], 8); printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR2", ECPGt_EOIT, ECPGt_EORT); #line 88 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 88 "execute.pgc" { ECPGdeallocate(__LINE__, 0, NULL, "f"); #line 89 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 89 "execute.pgc" sprintf (command, "select * from test where amount = $1"); { ECPGprepare(__LINE__, NULL, 0, "f", command); #line 93 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 93 "execute.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "f", ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 94 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 94 "execute.pgc" for (i=0, j=sqlca.sqlerrd[2]; i<j; i++) { /* exec sql begin declare section */ #line 99 "execute.pgc" char n [ 8 ] , l = letter [ i ] [ 0 ] ; #line 100 "execute.pgc" int a = amount [ i ] ; /* exec sql end declare section */ #line 101 "execute.pgc" strncpy(n, name[i], 8); printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } { ECPGdeallocate(__LINE__, 0, NULL, "f"); #line 107 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 107 "execute.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT); #line 108 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 108 "execute.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 109 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 109 "execute.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 110 "execute.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 110 "execute.pgc" return (0); }
int main(void) { #line 15 "rnull.pgc" char c [] = "abc " ; #line 15 "rnull.pgc" #line 16 "rnull.pgc" short s = 17 ; #line 16 "rnull.pgc" #line 17 "rnull.pgc" int i = - 74874 ; #line 17 "rnull.pgc" #line 18 "rnull.pgc" bool b = 1 ; #line 18 "rnull.pgc" #line 19 "rnull.pgc" float f = 3.71 ; #line 19 "rnull.pgc" #line 20 "rnull.pgc" long l = 487444 ; #line 20 "rnull.pgc" #line 21 "rnull.pgc" double dbl = 404.404 ; #line 21 "rnull.pgc" #line 22 "rnull.pgc" decimal dec ; #line 22 "rnull.pgc" #line 23 "rnull.pgc" date dat ; #line 23 "rnull.pgc" #line 24 "rnull.pgc" timestamp tmp ; #line 24 "rnull.pgc" ECPGdebug(1, stderr); /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 27 "rnull.pgc" { ECPGconnect(__LINE__, 1, "regress1" , NULL,NULL , NULL, 0); #line 29 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 29 "rnull.pgc" { ECPGdo(__LINE__, 1, 0, NULL, "create table test ( id int , c char ( 10 ) , s smallint , i int , b bool , f float , l bigint , dbl double precision , dec decimal , dat date , tmp timestamptz ) ", ECPGt_EOIT, ECPGt_EORT); #line 33 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 33 "rnull.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 34 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 34 "rnull.pgc" { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl ) values ( 1 , ? , ? , ? , ? , ? , ? , ? ) ", ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,&(s),(long)1,(long)1,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_float,&(f),(long)1,(long)1,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(l),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 38 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 38 "rnull.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 39 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 39 "rnull.pgc" rsetnull(CCHARTYPE, (char *) c); rsetnull(CSHORTTYPE, (char *) &s); rsetnull(CINTTYPE, (char *) &i); rsetnull(CBOOLTYPE, (char *) &b); rsetnull(CFLOATTYPE, (char *) &f); rsetnull(CLONGTYPE, (char *) &l); rsetnull(CDOUBLETYPE, (char *) &dbl); rsetnull(CDECIMALTYPE, (char *) &dec); rsetnull(CDATETYPE, (char *) &dat); rsetnull(CDTIMETYPE, (char *) &tmp); { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values ( 2 , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ", ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,&(s),(long)1,(long)1,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_float,&(f),(long)1,(long)1,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(l),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 54 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 54 "rnull.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 55 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 55 "rnull.pgc" printf("first select\n"); { ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1 ", ECPGt_EOIT, ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,&(s),(long)1,(long)1,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_float,&(f),(long)1,(long)1,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(l),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 61 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 61 "rnull.pgc" test_null(CCHARTYPE, (char *) c); test_null(CSHORTTYPE, (char *) &s); test_null(CINTTYPE, (char *) &i); test_null(CBOOLTYPE, (char *) &b); test_null(CFLOATTYPE, (char *) &f); test_null(CLONGTYPE, (char *) &l); test_null(CDOUBLETYPE, (char *) &dbl); test_null(CDECIMALTYPE, (char *) &dec); test_null(CDATETYPE, (char *) &dat); test_null(CDTIMETYPE, (char *) &tmp); printf("second select\n"); { ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2 ", ECPGt_EOIT, ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,&(s),(long)1,(long)1,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_float,&(f),(long)1,(long)1,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(l),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 78 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 78 "rnull.pgc" test_null(CCHARTYPE, (char *) c); test_null(CSHORTTYPE, (char *) &s); test_null(CINTTYPE, (char *) &i); test_null(CBOOLTYPE, (char *) &b); test_null(CFLOATTYPE, (char *) &f); test_null(CLONGTYPE, (char *) &l); test_null(CDOUBLETYPE, (char *) &dbl); test_null(CDECIMALTYPE, (char *) &dec); test_null(CDATETYPE, (char *) &dat); test_null(CDTIMETYPE, (char *) &tmp); { ECPGdo(__LINE__, 1, 0, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); #line 91 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 91 "rnull.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 92 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 92 "rnull.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 94 "rnull.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 94 "rnull.pgc" return 0; }
int main (void) { /* exec sql begin declare section */ #line 19 "array.pgc" int i = 1 , j ; #line 20 "array.pgc" int * did = & i ; #line 21 "array.pgc" short a [ 10 ] = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ; #line 22 "array.pgc" timestamp ts [ 10 ] ; #line 23 "array.pgc" date d [ 10 ] ; #line 24 "array.pgc" interval in [ 10 ] ; #line 25 "array.pgc" numeric n [ 10 ] ; #line 26 "array.pgc" char text [ 25 ] = "klmnopqrst" ; #line 27 "array.pgc" char * t = ( char * ) malloc ( 11 ) ; #line 28 "array.pgc" double f ; /* exec sql end declare section */ #line 29 "array.pgc" strcpy(t, "0123456789"); setlocale(LC_ALL, "C"); ECPGdebug(1, stderr); for (j = 0; j < 10; j++) { char str[20]; numeric *value; interval *inter; sprintf(str, "2000-1-1 0%d:00:00", j); ts[j] = PGTYPEStimestamp_from_asc(str, NULL); sprintf(str, "2000-1-1%d\n", j); d[j] = PGTYPESdate_from_asc(str, NULL); sprintf(str, "%d hours", j+10); inter = PGTYPESinterval_from_asc(str, NULL); in[j] = *inter; value = PGTYPESnumeric_new(); PGTYPESnumeric_from_int(j, value); n[j] = *value; } { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); #line 53 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 53 "array.pgc" { ECPGsetcommit(__LINE__, "on", NULL); #line 55 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 55 "array.pgc" { ECPGtrans(__LINE__, NULL, "begin work"); #line 57 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 57 "array.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) , ts timestamp [ 10 ] , n numeric [ 10 ] , d date [ 10 ] , inter interval [ 10 ] )", ECPGt_EOIT, ECPGt_EORT); #line 59 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 59 "array.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , $1 , $2 , $3 , $4 )", ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_date,&(d),(long)1,(long)10,sizeof(date), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 61 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 61 "array.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 140787.0 , 2 , $1 , $2 , $3 , $4 , $5 , $6 )", ECPGt_short,(a),(long)1,(long)10,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_date,&(d),(long)1,(long)10,sizeof(date), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 63 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 63 "array.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 14.07 , $1 , $2 , $3 , $4 , $5 , $6 , $7 )", ECPGt_int,&(did),(long)1,(long)0,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,(a),(long)1,(long)10,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_date,&(d),(long)1,(long)10,sizeof(date), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 65 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 65 "array.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 67 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 67 "array.pgc" for (j = 0; j < 10; j++) { ts[j] = PGTYPEStimestamp_from_asc("1900-01-01 00:00:00", NULL); d[j] = PGTYPESdate_from_asc("1900-01-01", NULL); in[j] = *PGTYPESinterval_new(); n[j] = *PGTYPESnumeric_new(); } { ECPGtrans(__LINE__, NULL, "begin work"); #line 75 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 75 "array.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select f , text from test where i = 1", ECPGt_EOIT, ECPGt_double,&(f),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 80 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 80 "array.pgc" printf("Found f=%f text=%10.10s\n", f, text); f=140787; { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , text , ts , n , d , inter from test where f = $1 ", ECPGt_double,&(f),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_short,(a),(long)1,(long)10,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_date,&(d),(long)1,(long)10,sizeof(date), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 88 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 88 "array.pgc" for (i = 0; i < 10; i++) printf("Found a[%d] = %d ts[%d] = %s n[%d] = %s d[%d] = %s in[%d] = %s\n", i, a[i], i, PGTYPEStimestamp_to_asc(ts[i]), i, PGTYPESnumeric_to_asc(&(n[i]), -1), i, PGTYPESdate_to_asc(d[i]), i, PGTYPESinterval_to_asc(&(in[i]))); printf("Found text=%10.10s\n", t); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a from test where f = $1 ", ECPGt_double,&(f),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 98 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 98 "array.pgc" printf("Found text=%s\n", text); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT); #line 102 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 102 "array.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 104 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 104 "array.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 106 "array.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 106 "array.pgc" free(t); return 0; }
int main(int argc, char* argv[]) { /* exec sql begin declare section */ #line 9 "quote.pgc" char var [ 25 ] ; #line 10 "quote.pgc" int i ; /* exec sql end declare section */ #line 11 "quote.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } #line 14 "quote.pgc" { ECPGsetcommit(__LINE__, "on", NULL); } #line 16 "quote.pgc" /* exec sql whenever sql_warning sqlprint ; */ #line 17 "quote.pgc" /* exec sql whenever sqlerror sqlprint ; */ #line 18 "quote.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table \"My_Table\" ( Item1 int , Item2 text ) ", ECPGt_EOIT, ECPGt_EORT); #line 20 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 20 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 20 "quote.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT, ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 22 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 22 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 22 "quote.pgc" printf("Standard conforming strings: %s\n", var); /* this is a\\b actually */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , 'a\\\\\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); #line 26 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 26 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 26 "quote.pgc" /* this is a\\b */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , E'a\\\\\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); #line 28 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 28 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 28 "quote.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT); #line 30 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 30 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 30 "quote.pgc" /* this is a\\\\b actually */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , 'a\\\\\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); #line 33 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 33 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 33 "quote.pgc" /* this is a\\b */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , E'a\\\\\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); #line 35 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 35 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 35 "quote.pgc" { ECPGtrans(__LINE__, NULL, "begin transaction "); #line 37 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 37 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 37 "quote.pgc" /* declare C cursor for select * from \"My_Table\" */ #line 38 "quote.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT); #line 40 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 40 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 40 "quote.pgc" /* exec sql whenever not found break ; */ #line 42 "quote.pgc" while (true) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 46 "quote.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 46 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 46 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 46 "quote.pgc" printf("value: %d %s\n", i, var); } { ECPGtrans(__LINE__, NULL, "rollback"); #line 50 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 50 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 50 "quote.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT); #line 51 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 51 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 51 "quote.pgc" { ECPGdisconnect(__LINE__, "ALL"); #line 53 "quote.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 53 "quote.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 53 "quote.pgc" return 0; }
int main(void) { /* exec sql begin declare section */ #line 49 "test_informix2.pgc" int c ; #line 50 "test_informix2.pgc" timestamp d ; #line 51 "test_informix2.pgc" timestamp e ; #line 52 "test_informix2.pgc" timestamp maxd ; #line 53 "test_informix2.pgc" char dbname [ 30 ] ; /* exec sql end declare section */ #line 54 "test_informix2.pgc" interval *intvl; /* exec sql whenever sqlerror sqlprint ; */ #line 58 "test_informix2.pgc" ECPGdebug(1, stderr); strcpy(dbname, "ecpg1_regression"); { ECPGconnect(__LINE__, 1, dbname , NULL, NULL , NULL, 0); #line 63 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 63 "test_informix2.pgc" sql_check("main", "connect", 0); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT); #line 66 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 66 "test_informix2.pgc" { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) )", ECPGt_EOIT, ECPGt_EORT); #line 68 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 68 "test_informix2.pgc" sql_check("main", "create", 0); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )", ECPGt_EOIT, ECPGt_EORT); #line 73 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 73 "test_informix2.pgc" sql_check("main", "insert", 0); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select max ( timestamp ) from history", ECPGt_EOIT, ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 78 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 78 "test_informix2.pgc" sql_check("main", "select max", 100); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select customerid , timestamp from history where timestamp = $1 limit 1", ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(c),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_timestamp,&(d),(long)1,(long)1,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 85 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 85 "test_informix2.pgc" sql_check("main", "select", 0); printf("Read in customer %d\n", c); intvl = PGTYPESinterval_from_asc("1 day 2 hours 24 minutes 65 seconds", NULL); PGTYPEStimestamp_add_interval(&d, intvl, &e); free(intvl); c++; { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( $1 , $2 , 'test' , 'test' )", ECPGt_int,&(c),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_timestamp,&(e),(long)1,(long)1,sizeof(timestamp), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 97 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 97 "test_informix2.pgc" sql_check("main", "update", 0); { ECPGtrans(__LINE__, NULL, "commit"); #line 100 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 100 "test_informix2.pgc" { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table history", ECPGt_EOIT, ECPGt_EORT); #line 102 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 102 "test_informix2.pgc" sql_check("main", "drop", 0); { ECPGtrans(__LINE__, NULL, "commit"); #line 105 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 105 "test_informix2.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 107 "test_informix2.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 107 "test_informix2.pgc" sql_check("main", "disconnect", 0); printf("All OK!\n"); exit(0); /* Table "public.history" Column | Type | Nullable --------------+-----------------------------+---------- customerid | integer | not null timestamp | timestamp without time zone | not null action_taken | character(5) | not null narrative | character varying(100) | */ }
int main() { /* exec sql begin declare section */ #line 9 "fetch.pgc" char str [ 25 ] ; #line 10 "fetch.pgc" int i , count = 1 ; /* exec sql end declare section */ #line 11 "fetch.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } #line 14 "fetch.pgc" /* exec sql whenever sql_warning sqlprint ; */ #line 16 "fetch.pgc" /* exec sql whenever sqlerror sqlprint ; */ #line 17 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table My_Table ( Item1 int , Item2 text )", ECPGt_EOIT, ECPGt_EORT); #line 19 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 19 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 19 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 1 , 'text1' )", ECPGt_EOIT, ECPGt_EORT); #line 21 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 21 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 21 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 2 , 'text2' )", ECPGt_EOIT, ECPGt_EORT); #line 22 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 22 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 22 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 3 , 'text3' )", ECPGt_EOIT, ECPGt_EORT); #line 23 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 23 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 23 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 4 , 'text4' )", ECPGt_EOIT, ECPGt_EORT); #line 24 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 24 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 24 "fetch.pgc" /* declare C cursor for select * from My_Table */ #line 26 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT); #line 28 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 28 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 28 "fetch.pgc" /* exec sql whenever not found break ; */ #line 30 "fetch.pgc" while (1) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 32 "fetch.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 32 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 32 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 32 "fetch.pgc" printf("%d: %s\n", i, str); } /* exec sql whenever not found continue ; */ #line 36 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT); #line 37 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 37 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 37 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 in C", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 39 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 39 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 39 "fetch.pgc" printf("%d: %s\n", i, str); /* declare D cursor for select * from My_Table where Item1 = $1 */ #line 42 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare D cursor for select * from My_Table where Item1 = $1", ECPGt_const,"1",(long)1,(long)1,strlen("1"), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 44 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 44 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 44 "fetch.pgc" /* exec sql whenever not found break ; */ #line 46 "fetch.pgc" while (1) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 48 "fetch.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 48 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 48 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 48 "fetch.pgc" printf("%d: %s\n", i, str); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close D", ECPGt_EOIT, ECPGt_EORT); #line 51 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 51 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 51 "fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table My_Table", ECPGt_EOIT, ECPGt_EORT); #line 53 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 53 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 53 "fetch.pgc" { ECPGdisconnect(__LINE__, "ALL"); #line 55 "fetch.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 55 "fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 55 "fetch.pgc" return 0; }
int main(void) { /* exec sql begin declare section */ #line 11 "cursor-ra-fetch.pgc" int id [ 8 ] , i ; #line 12 "cursor-ra-fetch.pgc" struct varchar_1 { int len; char arr[ 50 ]; } t [ 8 ] ; /* exec sql end declare section */ #line 13 "cursor-ra-fetch.pgc" int quit_loop; ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 18 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 18 "cursor-ra-fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT); #line 20 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 20 "cursor-ra-fetch.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ) , ( 'd' ) , ( 'e' ) , ( 'f' ) , ( 'g' ) , ( 'h' ) , ( 'i' ) , ( 'j' ) , ( 'k' ) , ( 'l' ) , ( 'm' ) , ( 'n' ) , ( 'o' ) , ( 'p' ) , ( 'q' ) , ( 'r' ) , ( 's' ) , ( 't' ) , ( 'u' ) , ( 'v' ) , ( 'w' ) , ( 'x' ) , ( 'y' ) , ( 'z' )", ECPGt_EOIT, ECPGt_EORT); #line 25 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 25 "cursor-ra-fetch.pgc" { ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL); #line 26 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 26 "cursor-ra-fetch.pgc" /* declare scroll_cur scroll cursor for select id , t from t1 order by id */ #line 28 "cursor-ra-fetch.pgc" /* declare scroll_cur4 scroll cursor for select id , t from t1 order by id */ #line 29 "cursor-ra-fetch.pgc" /* * Test FETCH ABSOLUTE N with an interval of 4 using positive positions. * Readahead is 8 so caching is in effect. */ printf("test scroll_cur for move absolute n (every 4th tuple forward, positive positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 38 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 38 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); for (i = 1; i < 33; i += 4) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 44 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 44 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr); else printf("\trow %d does not exist\n", i); } printf("\ntest scroll_cur for move absolute n (every 4th tuple backward, positive positions)\n"); for (i = 33; i >= 0; i -= 4) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 56 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 56 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr); else printf("\trow %d does not exist\n", i); } { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 64 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 64 "cursor-ra-fetch.pgc" /* * Test FETCH ABSOLUTE N with an interval of 4 using negative positions. * Readahead is 8 so caching is in effect. */ printf("\ntest scroll_cur for move absolute n (every 4th tuple backward, negative positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 73 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 73 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); for (i = -1; i > -33; i -= 4) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 79 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 79 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr); else printf("\trow %d does not exist\n", i); } printf("\ntest scroll_cur for move absolute n (every 4th tuple forward, negative positions)\n"); for (i = -33; i <= 0; i += 4) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 91 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 91 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr); else printf("\trow %d does not exist\n", i); } { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 99 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 99 "cursor-ra-fetch.pgc" /* * Test FETCH RELATIVE +/- 4 using positive positions * readahead is 8, so caching is in effect */ printf("\ntest scroll_cur for fetch relative 4 (positive positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 108 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 108 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); quit_loop = 0; while (!quit_loop) { for (i = 0; i < 8; i++) id[i] = 0, t[i].arr[0] = '\0'; { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "4", 0, "scroll_cur", ECPGst_normal, "fetch relative 4 in scroll_cur", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 117 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 117 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("fetch relative 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); else printf("fetch relative 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]); for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d\tt: %s\n", id[i], t[i].arr); quit_loop = (sqlca.sqlerrd[2] == 0); } printf("\ntest scroll_cur for fetch relative -4 (positive positions)\n"); quit_loop = 0; while (!quit_loop) { for (i = 0; i < 8; i++) id[i] = 0, t[i].arr[0] = '\0'; { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch relative - 4 in scroll_cur", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 134 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 134 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("fetch relative -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); else printf("fetch relative -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]); for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d\tt: %s\n", id[i], t[i].arr); quit_loop = (sqlca.sqlerrd[2] == 0); } { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 144 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 144 "cursor-ra-fetch.pgc" /* * Test FETCH RELATIVE +/- 4 using negative positions * readahead is 8, so caching is in effect */ printf("\ntest scroll_cur for fetch relative -4 (negative positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 153 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 153 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur", ECPGst_normal, "move absolute - 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT); #line 157 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 157 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur", ECPGst_normal, "move forward 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT); #line 160 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 160 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("move forward 1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); quit_loop = 0; while (!quit_loop) { for (i = 0; i < 8; i++) id[i] = 0, t[i].arr[0] = '\0'; { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch relative - 4 in scroll_cur", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 169 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 169 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("fetch relative -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); else printf("fetch relative -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]); for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d\tt: %s\n", id[i], t[i].arr); quit_loop = (sqlca.sqlerrd[2] == 0); } printf("\ntest scroll_cur for fetch relative 4 (negative positions)\n"); quit_loop = 0; while (!quit_loop) { for (i = 0; i < 8; i++) id[i] = 0, t[i].arr[0] = '\0'; { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "4", 0, "scroll_cur", ECPGst_normal, "fetch relative 4 in scroll_cur", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 186 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 186 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("fetch relative 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); else printf("fetch relative 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]); for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d\tt: %s\n", id[i], t[i].arr); quit_loop = (sqlca.sqlerrd[2] == 0); } { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 196 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 196 "cursor-ra-fetch.pgc" /* * Test FETCH FORWARD +/- 4 using positive positions * readahead is 8, so caching is in effect */ printf("\ntest scroll_cur for fetch forward 4 (positive positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 205 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 205 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); quit_loop = 0; while (!quit_loop) { for (i = 0; i < 8; i++) id[i] = 0, t[i].arr[0] = '\0'; { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "4", 0, "scroll_cur", ECPGst_normal, "fetch forward 4 in scroll_cur", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 214 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 214 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("fetch forward 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); else printf("fetch forward 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]); for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d\tt: %s\n", id[i], t[i].arr); quit_loop = (sqlca.sqlerrd[2] == 0); } printf("\ntest scroll_cur for fetch forward -4 (positive positions)\n"); quit_loop = 0; while (!quit_loop) { for (i = 0; i < 8; i++) id[i] = 0, t[i].arr[0] = '\0'; { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch forward - 4 in scroll_cur", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 231 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 231 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("fetch forward -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); else printf("fetch forward -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]); for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d\tt: %s\n", id[i], t[i].arr); quit_loop = (sqlca.sqlerrd[2] == 0); } { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 241 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 241 "cursor-ra-fetch.pgc" /* * Test FETCH FORWARD +/- 4 using negative positions * readahead is 8, so caching is in effect */ printf("\ntest scroll_cur for fetch forward -4 (negative positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 250 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 250 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur", ECPGst_normal, "move absolute - 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT); #line 254 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 254 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur", ECPGst_normal, "move forward 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT); #line 257 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 257 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("move forward 1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); quit_loop = 0; while (!quit_loop) { for (i = 0; i < 8; i++) id[i] = 0, t[i].arr[0] = '\0'; { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch forward - 4 in scroll_cur", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 266 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 266 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("fetch forward -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); else printf("fetch forward -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]); for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d\tt: %s\n", id[i], t[i].arr); quit_loop = (sqlca.sqlerrd[2] == 0); } printf("\ntest scroll_cur for fetch forward 4 (negative positions)\n"); quit_loop = 0; while (!quit_loop) { for (i = 0; i < 8; i++) id[i] = 0, t[i].arr[0] = '\0'; { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "4", 0, "scroll_cur", ECPGst_normal, "fetch forward 4 in scroll_cur", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 283 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 283 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("fetch forward 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate); else printf("fetch forward 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]); for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d\tt: %s\n", id[i], t[i].arr); quit_loop = (sqlca.sqlerrd[2] == 0); } { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 293 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 293 "cursor-ra-fetch.pgc" /* * Test FETCH ABSOLUTE N with an interval of 5 using positive positions. * Readahead is 4 so cache misses occur. * ecpglib will switch to plain ecpg_execute after 3 cache misses */ printf("\ntest scroll_cur4 for move absolute n (every 5th tuple forward, positive positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 303 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 303 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); for (i = 1; i < 35; i += 5) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 309 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 309 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr); else printf("\trow %d does not exist\n", i); } /* * Let's see caching recovers by fetching 2x the readahead size. * The cursor must be at the end now, with the cursor's pos, * backend_pos, atstart and atend correctly set. */ printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 325 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 325 "cursor-ra-fetch.pgc" for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d t: %s\n", id[i], t[i].arr); printf("\ntest scroll_cur4 for move absolute n (every 5th tuple backward, positive positions)\n"); for (i = 36; i >= 0; i -= 5) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 333 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 333 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr); else printf("\trow %d does not exist\n", i); } /* * Let's see caching recovers by fetching 2x the readahead size. * The cursor must be at the start+1 (pos == 1) now, * with the cursor's pos, backend_pos, atstart and atend * correctly set. */ printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 350 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 350 "cursor-ra-fetch.pgc" for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d t: %s\n", id[i], t[i].arr); { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 354 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 354 "cursor-ra-fetch.pgc" /* * Test FETCH ABSOLUTE N with an interval of 5 using negative positions. * Readahead is 4 so cache misses occur. * ecpglib will switch to plain ecpg_execute after 3 cache misses */ printf("\ntest scroll_cur4 for move absolute n (every 5th tuple backward, negative positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 364 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 364 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); for (i = -1; i > -35; i -= 5) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 370 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 370 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr); else printf("\trow %d does not exist\n", i); } /* * Let's see caching recovers by fetching 2x the readahead size. * The cursor must be at the start (pos == -27) now, * with the cursor's pos, backend_pos, atstart and atend * correctly set. */ printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 387 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 387 "cursor-ra-fetch.pgc" for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d t: %s\n", id[i], t[i].arr); printf("\ntest scroll_cur4 for move absolute n (every 5th tuple forward, negative positions)\n"); for (i = -36; i <= 0; i += 5) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 395 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 395 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr); else printf("\trow %d does not exist\n", i); } /* * Let's see caching recovers by fetching 2x the readahead size. * The cursor must be at the end-1 (pos == -1) now, * with the cursor's pos, backend_pos, atstart and atend * correctly set. */ printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 412 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 412 "cursor-ra-fetch.pgc" for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d t: %s\n", id[i], t[i].arr); { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 416 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 416 "cursor-ra-fetch.pgc" /* * Test FETCH RELATIVE +/- 5 using positive positions. * Readahead is 4 so cache misses occur. * ecpglib will switch to plain ecpg_execute after 3 cache misses */ printf("\ntest scroll_cur4 for fetch relative 5 (positive positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 426 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 426 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); quit_loop = 0; while (!quit_loop) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "5", 0, "scroll_cur4", ECPGst_normal, "fetch relative 5 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 433 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 433 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\tid: %d\tt: %s\n", id[0], t[0].arr); else printf("\tfetch returned empty\n"); quit_loop = (sqlca.sqlerrd[2] == 0); } /* * Let's see caching recovers by fetching 2x the readahead size. * The cursor must be at the end now, * with the cursor's pos, backend_pos, atstart and atend * correctly set. */ printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 451 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 451 "cursor-ra-fetch.pgc" for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d t: %s\n", id[i], t[i].arr); /* Exaggerate the number of tuples, move to the end. */ { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "100", 1, "scroll_cur4", ECPGst_normal, "move forward 100 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT); #line 456 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 456 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("move forward 100 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate); printf("\ntest scroll_cur4 for fetch relative -5 (positive positions)\n"); quit_loop = 0; while (!quit_loop) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 5", 0, "scroll_cur4", ECPGst_normal, "fetch relative - 5 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 465 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 465 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\tid: %d\tt: %s\n", id[0], t[0].arr); else printf("\tfetch returned empty\n"); quit_loop = (sqlca.sqlerrd[2] == 0); } /* * Let's see caching recovers by fetching 2x the readahead size. * The cursor must be at the start now, * with the cursor's pos, backend_pos, atstart and atend * correctly set. */ printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 483 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 483 "cursor-ra-fetch.pgc" for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d t: %s\n", id[i], t[i].arr); { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 487 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 487 "cursor-ra-fetch.pgc" /* * Test FETCH RELATIVE +/- 5 using negative positions. * Readahead is 4 so cache misses occur. * ecpglib will switch to plain ecpg_execute after 3 cache misses */ printf("\ntest scroll_cur4 for move relative -5 (negative positions)\n"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT); #line 497 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 497 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur4", ECPGst_normal, "move absolute - 1 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT); #line 501 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 501 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("move absolute -1 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur4", ECPGst_normal, "move forward 1 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT); #line 504 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 504 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("move forward 1 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate); quit_loop = 0; while (!quit_loop) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 5", 0, "scroll_cur4", ECPGst_normal, "fetch relative - 5 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 511 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 511 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\tid: %d\tt: %s\n", id[0], t[0].arr); else printf("\tfetch returned empty\n"); quit_loop = (sqlca.sqlerrd[2] == 0); } /* * Let's see caching recovers by fetching 2x the readahead size. * The cursor must be at the start now, * with the cursor's pos, backend_pos, atstart and atend * correctly set. */ printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 529 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 529 "cursor-ra-fetch.pgc" for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d t: %s\n", id[i], t[i].arr); /* Exaggerate the number of tuples, move to the start. */ { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "100", 1, "scroll_cur4", ECPGst_normal, "move backward 100 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT); #line 534 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 534 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) printf("move backward 100 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate); printf("\ntest scroll_cur for move relative 5 (negative positions)\n"); quit_loop = 0; while (!quit_loop) { { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "5", 0, "scroll_cur4", ECPGst_normal, "fetch relative 5 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 543 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 543 "cursor-ra-fetch.pgc" if (sqlca.sqlerrd[2] == 1) printf("\tid: %d\tt: %s\n", id[0], t[0].arr); else printf("\tfetch returned empty\n"); quit_loop = (sqlca.sqlerrd[2] == 0); } /* * Let's see caching recovers by fetching 2x the readahead size. * The cursor must be at the end now, * with the cursor's pos, backend_pos, atstart and atend * correctly set. */ printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, ECPGt_int,(id),(long)1,(long)8,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 561 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 561 "cursor-ra-fetch.pgc" for (i = 0; i < sqlca.sqlerrd[2]; i++) printf("\tid: %d t: %s\n", id[i], t[i].arr); { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL); #line 565 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 565 "cursor-ra-fetch.pgc" /* Drop the test table */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT); #line 569 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 569 "cursor-ra-fetch.pgc" { ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL); #line 570 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 570 "cursor-ra-fetch.pgc" { ECPGdisconnect(__LINE__, "ALL"); #line 572 "cursor-ra-fetch.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 572 "cursor-ra-fetch.pgc" return 0; }
int main(void) { /* exec sql begin declare section */ #line 19 "nan_test.pgc" int id ; #line 20 "nan_test.pgc" double d ; #line 21 "nan_test.pgc" numeric * num ; #line 22 "nan_test.pgc" char val [ 16 ] ; /* exec sql end declare section */ #line 23 "nan_test.pgc" ECPGdebug(1, stderr); /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 26 "nan_test.pgc" { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 28 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 28 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table nantest1 ( id int4 , d float8 )", ECPGt_EOIT, ECPGt_EORT); #line 30 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 30 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( 1 , 'nan' :: float8 ) , ( 2 , 'infinity' :: float8 ) , ( 3 , '-infinity' :: float8 )", ECPGt_EOIT, ECPGt_EORT); #line 31 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 31 "nan_test.pgc" /* declare cur cursor for select id , d , d from nantest1 */ #line 33 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT); #line 34 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 34 "nan_test.pgc" while (1) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(d),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 37 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 37 "nan_test.pgc" if (sqlca.sqlcode) break; if (isnan(d)) printf("%d NaN '%s'\n", id, val); else if (isinf(d)) printf("%d %sInf '%s'\n", id, (d < 0 ? "-" : "+"), val); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( $1 + 3 , $2 )", ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(d),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 45 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 45 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( $1 + 6 , $2 )", ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 46 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 46 "nan_test.pgc" } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); #line 48 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 48 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT); #line 50 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 50 "nan_test.pgc" while (1) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_double,&(d),(long)1,(long)1,sizeof(double), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 53 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 53 "nan_test.pgc" if (sqlca.sqlcode) break; if (isinf(d)) printf("%d %sInf '%s'\n", id, (d < 0 ? "-" : "+"), val); if (isnan(d)) printf("%d NaN '%s'\n", id, val); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); #line 61 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 61 "nan_test.pgc" num = PGTYPESnumeric_new(); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table nantest2 ( id int4 , d numeric )", ECPGt_EOIT, ECPGt_EORT); #line 65 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 65 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 4 , 'nan' :: numeric )", ECPGt_EOIT, ECPGt_EORT); #line 66 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 66 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id , d , d from nantest2 where id = 4", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 68 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 68 "nan_test.pgc" printf("%d %s '%s'\n", id, (num->sign == NUMERIC_NAN ? "NaN" : "not NaN"), val); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 5 , $1 )", ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 72 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 72 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 6 , $1 )", ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 73 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 73 "nan_test.pgc" /* declare cur1 cursor for select id , d , d from nantest2 */ #line 75 "nan_test.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT); #line 76 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 76 "nan_test.pgc" while (1) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur1", ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 79 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 79 "nan_test.pgc" if (sqlca.sqlcode) break; printf("%d %s '%s'\n", id, (num->sign == NUMERIC_NAN ? "NaN" : "not NaN"), val); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT); #line 84 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 84 "nan_test.pgc" PGTYPESnumeric_free(num); { ECPGtrans(__LINE__, NULL, "rollback"); #line 88 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 88 "nan_test.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 89 "nan_test.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 89 "nan_test.pgc" return (0); }
int main() { /* exec sql begin declare section */ #line 10 "parser.pgc" int item [ 3 ] , ind [ 3 ] , i ; /* exec sql end declare section */ #line 11 "parser.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } #line 14 "parser.pgc" { ECPGsetcommit(__LINE__, "on", NULL); } #line 16 "parser.pgc" /* exec sql whenever sql_warning sqlprint ; */ #line 17 "parser.pgc" /* exec sql whenever sqlerror sqlprint ; */ #line 18 "parser.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT); #line 20 "parser.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 20 "parser.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 20 "parser.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t select 1 , nullif ( y - 1 , 0 ) from generate_series ( 1 , 3 ) with ordinality as series ( x , y )", ECPGt_EOIT, ECPGt_EORT); #line 24 "parser.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 24 "parser.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 24 "parser.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, ECPGt_int,(item),(long)1,(long)3,sizeof(int), ECPGt_int,(ind),(long)1,(long)3,sizeof(int), ECPGt_EORT); #line 26 "parser.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 26 "parser.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 26 "parser.pgc" for (i=0; i<3; i++) printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter table T alter Item1 type bigint", ECPGt_EOIT, ECPGt_EORT); #line 31 "parser.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 31 "parser.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 31 "parser.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter table T alter column Item2 set data type smallint", ECPGt_EOIT, ECPGt_EORT); #line 32 "parser.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 32 "parser.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 32 "parser.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT); #line 34 "parser.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 34 "parser.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 34 "parser.pgc" { ECPGdisconnect(__LINE__, "ALL"); #line 36 "parser.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 36 "parser.pgc" if (sqlca.sqlcode < 0) sqlprint(); } #line 36 "parser.pgc" return 0; }
int main () { /* EXEC SQL BEGIN DECLARE SECTION; char *fname = "/tmp/foo"; EXEC SQL END DECLARE SECTION; */ ECPGdebug (1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); #line 19 "copystdout.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 19 "copystdout.pgc" { ECPGdo(__LINE__, 0, 1, NULL, "create table foo ( a int , b varchar ) ", ECPGt_EOIT, ECPGt_EORT); #line 20 "copystdout.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 20 "copystdout.pgc" { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values ( 5 , 'abc' ) ", ECPGt_EOIT, ECPGt_EORT); #line 21 "copystdout.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 21 "copystdout.pgc" { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values ( 6 , 'def' ) ", ECPGt_EOIT, ECPGt_EORT); #line 22 "copystdout.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 22 "copystdout.pgc" { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values ( 7 , 'ghi' ) ", ECPGt_EOIT, ECPGt_EORT); #line 23 "copystdout.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 23 "copystdout.pgc" /* produces expected file "/tmp/foo" */ /* EXEC SQL COPY foo TO:fname WITH DELIMITER ','; */ /* printf ("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode); */ { ECPGdo(__LINE__, 0, 1, NULL, "copy foo to stdout with delimiter ','", ECPGt_EOIT, ECPGt_EORT); #line 29 "copystdout.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 29 "copystdout.pgc" printf ("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode); { ECPGdisconnect(__LINE__, "CURRENT"); #line 32 "copystdout.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 32 "copystdout.pgc" return 0; }
int main(void) { /* exec sql begin declare section */ /* char **d8=0; */ /* int *i8=0; */ #line 9 "dynalloc.pgc" int * d1 = 0 ; #line 10 "dynalloc.pgc" double * d2 = 0 ; #line 11 "dynalloc.pgc" char ** d3 = 0 ; #line 12 "dynalloc.pgc" char ** d4 = 0 ; #line 13 "dynalloc.pgc" char ** d5 = 0 ; #line 14 "dynalloc.pgc" char ** d6 = 0 ; #line 15 "dynalloc.pgc" char ** d7 = 0 ; #line 17 "dynalloc.pgc" char ** d9 = 0 ; #line 18 "dynalloc.pgc" int * i1 = 0 ; #line 19 "dynalloc.pgc" int * i2 = 0 ; #line 20 "dynalloc.pgc" int * i3 = 0 ; #line 21 "dynalloc.pgc" int * i4 = 0 ; #line 22 "dynalloc.pgc" int * i5 = 0 ; #line 23 "dynalloc.pgc" int * i6 = 0 ; #line 24 "dynalloc.pgc" int * i7 = 0 ; #line 26 "dynalloc.pgc" int * i9 = 0 ; /* exec sql end declare section */ #line 27 "dynalloc.pgc" int i; ECPGdebug(1, stderr); /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 32 "dynalloc.pgc" { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 33 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 33 "dynalloc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to mdy", ECPGt_EOIT, ECPGt_EORT); #line 35 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 35 "dynalloc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( a serial , b numeric ( 12 , 3 ) , c varchar , d varchar ( 3 ) , e char ( 4 ) , f timestamptz , g boolean , h box , i inet )", ECPGt_EOIT, ECPGt_EORT); #line 37 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 37 "dynalloc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( b , c , d , e , f , g , h , i ) values ( 23.456 , 'varchar' , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , true , '(1,2,3,4)' , '2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128' )", ECPGt_EOIT, ECPGt_EORT); #line 38 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 38 "dynalloc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( b , c , d , e , f , g , h , i ) values ( 2.446456 , null , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , false , null , null )", ECPGt_EOIT, ECPGt_EORT); #line 39 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 39 "dynalloc.pgc" ECPGallocate_desc(__LINE__, "mydesc"); #line 41 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( ); #line 41 "dynalloc.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , b , c , d , e , f , g , h , i from test order by a", ECPGt_EOIT, ECPGt_descriptor, "mydesc", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 42 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 42 "dynalloc.pgc" { ECPGget_desc(__LINE__, "mydesc", 1,ECPGd_indicator, ECPGt_int,&(i1),(long)1,(long)0,sizeof(int), ECPGd_data, ECPGt_int,&(d1),(long)1,(long)0,sizeof(int), ECPGd_EODT); #line 43 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 43 "dynalloc.pgc" { ECPGget_desc(__LINE__, "mydesc", 2,ECPGd_indicator, ECPGt_int,&(i2),(long)1,(long)0,sizeof(int), ECPGd_data, ECPGt_double,&(d2),(long)1,(long)0,sizeof(double), ECPGd_EODT); #line 44 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 44 "dynalloc.pgc" { ECPGget_desc(__LINE__, "mydesc", 3,ECPGd_indicator, ECPGt_int,&(i3),(long)1,(long)0,sizeof(int), ECPGd_data, ECPGt_char,&(d3),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); #line 45 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 45 "dynalloc.pgc" { ECPGget_desc(__LINE__, "mydesc", 4,ECPGd_indicator, ECPGt_int,&(i4),(long)1,(long)0,sizeof(int), ECPGd_data, ECPGt_char,&(d4),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); #line 46 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 46 "dynalloc.pgc" { ECPGget_desc(__LINE__, "mydesc", 5,ECPGd_indicator, ECPGt_int,&(i5),(long)1,(long)0,sizeof(int), ECPGd_data, ECPGt_char,&(d5),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); #line 47 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 47 "dynalloc.pgc" { ECPGget_desc(__LINE__, "mydesc", 6,ECPGd_indicator, ECPGt_int,&(i6),(long)1,(long)0,sizeof(int), ECPGd_data, ECPGt_char,&(d6),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); #line 48 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 48 "dynalloc.pgc" { ECPGget_desc(__LINE__, "mydesc", 7,ECPGd_indicator, ECPGt_int,&(i7),(long)1,(long)0,sizeof(int), ECPGd_data, ECPGt_char,&(d7),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); #line 49 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 49 "dynalloc.pgc" /* skip box for now */ /* exec sql get descriptor mydesc value 8 :d8=DATA, :i8=INDICATOR; */ { ECPGget_desc(__LINE__, "mydesc", 9,ECPGd_indicator, ECPGt_int,&(i9),(long)1,(long)0,sizeof(int), ECPGd_data, ECPGt_char,&(d9),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); #line 52 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 52 "dynalloc.pgc" printf("Result:\n"); for (i=0;i<sqlca.sqlerrd[2];++i) { if (i1[i]) printf("NULL, "); else printf("%d, ",d1[i]); if (i2[i]) printf("NULL, "); else printf("%f, ",d2[i]); if (i3[i]) printf("NULL, "); else printf("'%s', ",d3[i]); if (i4[i]) printf("NULL, "); else printf("'%s', ",d4[i]); if (i5[i]) printf("NULL, "); else printf("'%s', ",d5[i]); if (i6[i]) printf("NULL, "); else printf("'%s', ",d6[i]); if (i7[i]) printf("NULL, "); else printf("'%s', ",d7[i]); if (i9[i]) printf("NULL, "); else printf("'%s', ",d9[i]); printf("\n"); } ECPGfree_auto_mem(); printf("\n"); ECPGdeallocate_desc(__LINE__, "mydesc"); #line 86 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( ); #line 86 "dynalloc.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 87 "dynalloc.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 87 "dynalloc.pgc" return 0; }
static void* fn(void* arg) #endif { int i; /* exec sql begin declare section */ #line 39 "alloc.pgc" int value ; #line 40 "alloc.pgc" char name [ 100 ] ; #line 41 "alloc.pgc" char ** r = NULL ; /* exec sql end declare section */ #line 42 "alloc.pgc" value = (long)arg; sprintf(name, "Connection: %d", value); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , name, 0); #line 47 "alloc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 47 "alloc.pgc" { ECPGsetcommit(__LINE__, "on", NULL); #line 48 "alloc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 48 "alloc.pgc" for (i = 1; i <= REPEATS; ++i) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select relname from pg_class where relname = 'pg_class'", ECPGt_EOIT, ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 51 "alloc.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 51 "alloc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 51 "alloc.pgc" free(r); r = NULL; } { ECPGdisconnect(__LINE__, name); #line 55 "alloc.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 55 "alloc.pgc" return 0; }
static void print2(void) { fprintf(stderr, "Found another error\n"); sqlprint(); }
int main() { /* exec sql begin declare section */ typedef struct { #line 30 "array_of_struct.pgc" struct varchar_name_30 { int len; char arr[ 50 ]; } name ; #line 31 "array_of_struct.pgc" int phone ; } customer2 ; #line 32 "array_of_struct.pgc" #line 26 "array_of_struct.pgc" customer custs1 [ 10 ] ; #line 27 "array_of_struct.pgc" cust_ind inds [ 10 ] ; #line 33 "array_of_struct.pgc" customer2 custs2 [ 10 ] ; #line 38 "array_of_struct.pgc" struct customer3 { #line 36 "array_of_struct.pgc" struct varchar_name_36 { int len; char arr[ 50 ]; } name ; #line 37 "array_of_struct.pgc" int phone ; } custs3 [ 10 ] ; #line 43 "array_of_struct.pgc" struct customer4 { #line 41 "array_of_struct.pgc" struct varchar_name_41 { int len; char arr[ 50 ]; } name ; #line 42 "array_of_struct.pgc" int phone ; } custs4 ; #line 44 "array_of_struct.pgc" int r ; #line 45 "array_of_struct.pgc" struct varchar_onlyname_45 { int len; char arr[ 50 ]; } onlyname [2] ; /* exec sql end declare section */ #line 46 "array_of_struct.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 50 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 50 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 50 "array_of_struct.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table customers ( c varchar ( 50 ) , p int )", ECPGt_EOIT, ECPGt_EORT); #line 52 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 52 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 52 "array_of_struct.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'John Doe' , '12345' )", ECPGt_EOIT, ECPGt_EORT); #line 53 "array_of_struct.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 53 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 53 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 53 "array_of_struct.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'Jane Doe' , '67890' )", ECPGt_EOIT, ECPGt_EORT); #line 54 "array_of_struct.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 54 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 54 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 54 "array_of_struct.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, ECPGt_varchar,&(custs1->name),(long)50,(long)10,sizeof( customer ), ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_int,&(custs1->phone),(long)1,(long)10,sizeof( customer ), ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT); #line 56 "array_of_struct.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 56 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 56 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 56 "array_of_struct.pgc" printf("custs1:\n"); for (r = 0; r < 2; r++) { printf( "name - %s\n", custs1[r].name.arr ); printf( "phone - %d\n", custs1[r].phone ); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, ECPGt_varchar,&(custs2->name),(long)50,(long)10,sizeof( customer2 ), ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_int,&(custs2->phone),(long)1,(long)10,sizeof( customer2 ), ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT); #line 64 "array_of_struct.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 64 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 64 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 64 "array_of_struct.pgc" printf("\ncusts2:\n"); for (r = 0; r < 2; r++) { printf( "name - %s\n", custs2[r].name.arr ); printf( "phone - %d\n", custs2[r].phone ); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, ECPGt_varchar,&(custs3->name),(long)50,(long)10,sizeof( struct customer3 ), ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_int,&(custs3->phone),(long)1,(long)10,sizeof( struct customer3 ), ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT); #line 72 "array_of_struct.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 72 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 72 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 72 "array_of_struct.pgc" printf("\ncusts3:\n"); for (r = 0; r < 2; r++) { printf( "name - %s\n", custs3[r].name.arr ); printf( "phone - %d\n", custs3[r].phone ); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 1", ECPGt_EOIT, ECPGt_varchar,&(custs4.name),(long)50,(long)1,sizeof(struct varchar_name_41), ECPGt_short,&(inds[0].name_ind),(long)1,(long)1,sizeof(short), ECPGt_int,&(custs4.phone),(long)1,(long)1,sizeof(int), ECPGt_short,&(inds[0].phone_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT); #line 80 "array_of_struct.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 80 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 80 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 80 "array_of_struct.pgc" printf("\ncusts4:\n"); printf( "name - %s\n", custs4.name.arr ); printf( "phone - %d\n", custs4.phone ); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select c from customers limit 2", ECPGt_EOIT, ECPGt_varchar,(onlyname),(long)50,(long)2,sizeof(struct varchar_onlyname_45), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 85 "array_of_struct.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 85 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 85 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 85 "array_of_struct.pgc" printf("\nname:\n"); for (r = 0; r < 2; r++) { printf( "name - %s\n", onlyname[r].arr ); } { ECPGdisconnect(__LINE__, "ALL"); #line 92 "array_of_struct.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 92 "array_of_struct.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 92 "array_of_struct.pgc" return( 0 ); }
int main(void) { #line 26 "whenever.pgc" int i ; #line 26 "whenever.pgc" #line 27 "whenever.pgc" char c [ 6 ] ; #line 27 "whenever.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 31 "whenever.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 31 "whenever.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( i int , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); #line 32 "whenever.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 32 "whenever.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 1 , 'abcdefghij' )", ECPGt_EOIT, ECPGt_EORT); #line 33 "whenever.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 33 "whenever.pgc" /* exec sql whenever sql_warning do warn ( ) ; */ #line 35 "whenever.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(c),(long)6,(long)1,(6)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 36 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 36 "whenever.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 36 "whenever.pgc" { ECPGtrans(__LINE__, NULL, "rollback"); #line 37 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 37 "whenever.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 37 "whenever.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 39 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 39 "whenever.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 39 "whenever.pgc" { ECPGtrans(__LINE__, NULL, "rollback"); #line 40 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 40 "whenever.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 40 "whenever.pgc" /* exec sql whenever sqlerror do print ( \"select\" ) ; */ #line 42 "whenever.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 43 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 43 "whenever.pgc" if (sqlca.sqlcode < 0) print ( "select" );} #line 43 "whenever.pgc" { ECPGtrans(__LINE__, NULL, "rollback"); #line 44 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 44 "whenever.pgc" if (sqlca.sqlcode < 0) print ( "select" );} #line 44 "whenever.pgc" /* exec sql whenever sqlerror call print2 ( ) ; */ #line 46 "whenever.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 47 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 47 "whenever.pgc" if (sqlca.sqlcode < 0) print2 ( );} #line 47 "whenever.pgc" { ECPGtrans(__LINE__, NULL, "rollback"); #line 48 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 48 "whenever.pgc" if (sqlca.sqlcode < 0) print2 ( );} #line 48 "whenever.pgc" /* exec sql whenever sqlerror continue ; */ #line 50 "whenever.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 51 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( );} #line 51 "whenever.pgc" { ECPGtrans(__LINE__, NULL, "rollback"); #line 52 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( );} #line 52 "whenever.pgc" /* exec sql whenever sqlerror goto error ; */ #line 54 "whenever.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from nonexistant", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 55 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 55 "whenever.pgc" if (sqlca.sqlcode < 0) goto error;} #line 55 "whenever.pgc" printf("Should not be reachable\n"); error: { ECPGtrans(__LINE__, NULL, "rollback"); #line 59 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 59 "whenever.pgc" if (sqlca.sqlcode < 0) goto error;} #line 59 "whenever.pgc" /* exec sql whenever sqlerror stop ; */ #line 61 "whenever.pgc" /* This cannot fail, thus we don't get an exit value not equal 0. */ /* However, it still test the precompiler output. */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 64 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 64 "whenever.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 64 "whenever.pgc" { ECPGtrans(__LINE__, NULL, "rollback"); #line 65 "whenever.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 65 "whenever.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 65 "whenever.pgc" exit (0); }
static void* fn(void* arg) #endif { int i; /* exec sql begin declare section */ #line 39 "prep.pgc" int value ; #line 40 "prep.pgc" char name [ 100 ] ; #line 41 "prep.pgc" char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ; /* exec sql end declare section */ #line 42 "prep.pgc" value = (long)arg; sprintf(name, "Connection: %d", value); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , name, 0); #line 47 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 47 "prep.pgc" { ECPGsetcommit(__LINE__, "on", NULL); #line 48 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 48 "prep.pgc" for (i = 1; i <= REPEATS; ++i) { { ECPGprepare(__LINE__, NULL, 0, "i", query); #line 51 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 51 "prep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", ECPGt_int,&(value),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 52 "prep.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint(); #line 52 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 52 "prep.pgc" } { ECPGdeallocate(__LINE__, 0, NULL, "i"); #line 54 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 54 "prep.pgc" { ECPGdisconnect(__LINE__, name); #line 55 "prep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 55 "prep.pgc" return 0; }
int main(void) { /* exec sql begin declare section */ #line 10 "define.pgc" int i ; #line 11 "define.pgc" char s [ 200 ] ; /* exec sql end declare section */ #line 12 "define.pgc" ECPGdebug(1, stderr); /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 16 "define.pgc" { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); #line 17 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 17 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( a int , b text )", ECPGt_EOIT, ECPGt_EORT); #line 19 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 19 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'abcdef' )", ECPGt_EOIT, ECPGt_EORT); #line 20 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 20 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'defined' )", ECPGt_EOIT, ECPGt_EORT); #line 23 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 23 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'someothervar not defined' )", ECPGt_EOIT, ECPGt_EORT); #line 31 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 31 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1 , 29 :: text || '-' || 'abcdef'", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(s),(long)200,(long)1,(200)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 36 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 36 "define.pgc" printf("i: %d, s: %s\n", i, s); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'no string' )", ECPGt_EOIT, ECPGt_EORT); #line 42 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 42 "define.pgc" /* no value */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT); #line 53 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 53 "define.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 56 "define.pgc" if (sqlca.sqlcode < 0) sqlprint ( );} #line 56 "define.pgc" return 0; }
static void test(void) { /* exec sql begin declare section */ #line 10 "autoprep.pgc" int item [ 4 ] , ind [ 4 ] , i = 1 ; #line 11 "autoprep.pgc" int item1 , ind1 ; #line 12 "autoprep.pgc" char sqlstr [ 64 ] = "SELECT item2 FROM T ORDER BY item2 NULLS LAST" ; /* exec sql end declare section */ #line 13 "autoprep.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } #line 16 "autoprep.pgc" /* exec sql whenever sql_warning sqlprint ; */ #line 18 "autoprep.pgc" /* exec sql whenever sqlerror sqlprint ; */ #line 19 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT); #line 21 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 21 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 21 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT); #line 23 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 23 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 23 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1 )", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 24 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 24 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 24 "autoprep.pgc" i++; { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1 )", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 26 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 26 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 26 "autoprep.pgc" { ECPGprepare(__LINE__, NULL, 0, "i", " insert into T values ( 1 , 2 ) "); #line 27 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 27 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 27 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", ECPGt_EOIT, ECPGt_EORT); #line 28 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 28 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 28 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, ECPGt_int,(item),(long)1,(long)4,sizeof(int), ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT); #line 30 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 30 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 30 "autoprep.pgc" for (i=0; i<4; i++) printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]); /* declare C cursor for select Item1 from T */ #line 35 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT); #line 37 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 37 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 37 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 39 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 39 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 39 "autoprep.pgc" printf("i = %d\n", i); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT); #line 42 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 42 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 42 "autoprep.pgc" { ECPGprepare(__LINE__, NULL, 0, "stmt1", sqlstr); #line 44 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 44 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 44 "autoprep.pgc" /* declare cur1 cursor for $1 */ #line 46 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 48 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 48 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 48 "autoprep.pgc" /* exec sql whenever not found break ; */ #line 50 "autoprep.pgc" i = 0; while (1) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT, ECPGt_int,&(item1),(long)1,(long)1,sizeof(int), ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_EORT); #line 55 "autoprep.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 55 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 55 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 55 "autoprep.pgc" printf("item[%d] = %d\n", i, ind1 ? -1 : item1); i++; } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT); #line 60 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 60 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 60 "autoprep.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT); #line 62 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 62 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 62 "autoprep.pgc" { ECPGdisconnect(__LINE__, "ALL"); #line 64 "autoprep.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 64 "autoprep.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 64 "autoprep.pgc" }
int main(int argc, char* argv[]) { /* exec sql begin declare section */ #line 9 "insupd.pgc" int i1 [ 3 ] , i2 [ 3 ] ; /* exec sql end declare section */ #line 10 "insupd.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } #line 13 "insupd.pgc" /* exec sql whenever sql_warning sqlprint ; */ #line 15 "insupd.pgc" /* exec sql whenever sqlerror sqlprint ; */ #line 16 "insupd.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table insupd_test ( a int , b int ) ", ECPGt_EOIT, ECPGt_EORT); #line 18 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 18 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 18 "insupd.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 1 , 1 ) ", ECPGt_EOIT, ECPGt_EORT); #line 20 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 20 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 20 "insupd.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 2 , 2 ) ", ECPGt_EOIT, ECPGt_EORT); #line 21 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 21 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 21 "insupd.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 3 , 3 ) ", ECPGt_EOIT, ECPGt_EORT); #line 22 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 22 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 22 "insupd.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = a + 1 ", ECPGt_EOIT, ECPGt_EORT); #line 24 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 24 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 24 "insupd.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set ( a , b )= ( 5 , 5 ) where a = 4 ", ECPGt_EOIT, ECPGt_EORT); #line 25 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 25 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 25 "insupd.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = 4 where a = 3 ", ECPGt_EOIT, ECPGt_EORT); #line 26 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 26 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 26 "insupd.pgc" ; { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , b from insupd_test order by a ", ECPGt_EOIT, ECPGt_int,(i1),(long)1,(long)3,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(i2),(long)1,(long)3,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 28 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 28 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 28 "insupd.pgc" printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]); { ECPGdisconnect(__LINE__, "ALL"); #line 32 "insupd.pgc" if (sqlca.sqlwarn[0] == 'W') sqlprint(); #line 32 "insupd.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 32 "insupd.pgc" return 0; }
int main(void) { /* exec sql begin declare section */ typedef char string [ 8 ] ; #line 21 "define.pgc" #line 22 "define.pgc" intarray amount ; #line 23 "define.pgc" char name [ 6 ] [ 8 ] ; #line 24 "define.pgc" char letter [ 6 ] [ 1 ] ; #if 0 #line 26 "define.pgc" int not_used ; #endif /* exec sql end declare section */ #line 29 "define.pgc" int i,j; ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 34 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 34 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT); #line 36 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 36 "define.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 37 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 37 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' ) ", ECPGt_EOIT, ECPGt_EORT); #line 39 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 39 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' ) ", ECPGt_EOIT, ECPGt_EORT); #line 40 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 40 "define.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 41 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 41 "define.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test ", ECPGt_EOIT, ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,(amount),(long)1,(long)6,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 43 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 43 "define.pgc" for (i=0, j=sqlca.sqlerrd[2]; i<j; i++) { /* exec sql begin declare section */ #line 48 "define.pgc" char n [ 8 ] , l = letter [ i ] [ 0 ] ; #line 49 "define.pgc" int a = amount [ i ] ; /* exec sql end declare section */ #line 50 "define.pgc" strncpy(n, name[i], 8); printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test ", ECPGt_EOIT, ECPGt_EORT); #line 56 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 56 "define.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 57 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 57 "define.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 58 "define.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 58 "define.pgc" return (0); }
void *test_thread(void *arg) { long threadnum = (long)arg; /* exec sql begin declare section */ #line 101 "thread.pgc" int l_i ; #line 102 "thread.pgc" char l_connection [ 128 ] ; /* exec sql end declare section */ #line 103 "thread.pgc" /* build up connection name, and connect to database */ #ifndef _MSC_VER snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); #else _snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); #endif /* exec sql whenever sqlerror sqlprint ; */ #line 111 "thread.pgc" { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0); #line 112 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 112 "thread.pgc" if( sqlca.sqlcode != 0 ) { printf("%s: ERROR: cannot connect to database!\n", l_connection); return( NULL ); } { ECPGtrans(__LINE__, l_connection, "begin"); #line 118 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 118 "thread.pgc" /* insert into test_thread table */ for( l_i = 1; l_i <= iterations; l_i++ ) { { ECPGdo(__LINE__, 0, 1, l_connection, 0, ECPGst_normal, "insert into test_thread ( thread , iteration ) values ( $1 , $2 )", ECPGt_char,(l_connection),(long)128,(long)1,(128)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 123 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 123 "thread.pgc" if( sqlca.sqlcode != 0 ) printf("%s: ERROR: insert failed!\n", l_connection); } /* all done */ { ECPGtrans(__LINE__, l_connection, "commit"); #line 129 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 129 "thread.pgc" { ECPGdisconnect(__LINE__, l_connection); #line 130 "thread.pgc" if (sqlca.sqlcode < 0) sqlprint();} #line 130 "thread.pgc" return( NULL ); }