int main(void) { ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } #line 13 "strings.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);} #line 15 "strings.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 'abcdef' , N'abcdef' as foo , E'abc\\bdef' as \"foo\" , U&'d\\0061t\\0061' as U&\"foo\" , U&'d!+000061t!+000061' uescape '!' , $foo$abc$def$foo$", ECPGt_EOIT, ECPGt_char,&(s1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(s2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(s3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(s4),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(s5),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(s6),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 23 "strings.pgc" printf("%s %s %s %s %s %s\n", s1, s2, s3, s4, s5, s6); { ECPGdisconnect(__LINE__, "CURRENT");} #line 27 "strings.pgc" exit (0); }
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 db_disconnect() { { ECPGdisconnect(__LINE__, "CURRENT"); } #line 119 "main.pgs" printf("disconnect --OK\n"); }
int main(void) { ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } #line 17 "comment.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); } #line 19 "comment.pgc" exit (0); }
int main(void) { ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "main", 0); } #line 13 "test4.pgc" { ECPGsetconn(__LINE__, "main");} #line 15 "test4.pgc" { ECPGdisconnect(__LINE__, "DEFAULT");} #line 17 "test4.pgc" return (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) { /* exec sql begin declare section */ #line 23 "cursor.pgc" char * stmt1 = "SELECT id, t FROM t1" ; #line 24 "cursor.pgc" char * curname1 = CURNAME ; #line 25 "cursor.pgc" char * curname2 = CURNAME ; #line 26 "cursor.pgc" char * curname3 = CURNAME ; #line 27 "cursor.pgc" struct varchar_1 { int len; char arr[ 50 ]; } curname4 ; #line 28 "cursor.pgc" char * curname5 = CURNAME ; #line 29 "cursor.pgc" int count ; #line 30 "cursor.pgc" int id ; #line 31 "cursor.pgc" char t [ 64 ] ; /* exec sql end declare section */ #line 32 "cursor.pgc" char msg[128]; ECPGdebug(1, stderr); strcpy(msg, "connect"); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "test1", 0); #line 39 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 39 "cursor.pgc" { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "test2", 0); #line 40 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 40 "cursor.pgc" strcpy(msg, "set"); { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); #line 43 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 43 "cursor.pgc" strcpy(msg, "create"); { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT); #line 46 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 46 "cursor.pgc" { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT); #line 47 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 47 "cursor.pgc" strcpy(msg, "insert"); { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT); #line 50 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 50 "cursor.pgc" { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT); #line 51 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 51 "cursor.pgc" { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT); #line 52 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 52 "cursor.pgc" { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT); #line 53 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 53 "cursor.pgc" { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'e' )", ECPGt_EOIT, ECPGt_EORT); #line 54 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 54 "cursor.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, "test1", "commit", 0, 0, 0, NULL); #line 57 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 57 "cursor.pgc" { ECPGtrans(__LINE__, "test2", "commit", 0, 0, 0, NULL); #line 58 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 58 "cursor.pgc" /* Dynamic cursorname test with INTO list in FETCH stmts */ strcpy(msg, "declare"); ECPGset_var( 0, &( curname1 ), __LINE__);\ /* declare $0 no scroll cursor for select id , t from t1 */ #line 64 "cursor.pgc" strcpy(msg, "open"); { ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname1, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 67 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 67 "cursor.pgc" strcpy(msg, "fetch from"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname1, ECPGst_normal, "fetch forward from $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 70 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 70 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname1, ECPGst_normal, "fetch forward $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 74 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 74 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch 1 from"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname1, ECPGst_normal, "fetch 1 from $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 78 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 78 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch :count from"); count = 1; { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname1, ECPGst_normal, "fetch $0 from $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 83 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 83 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "move in"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", 1, curname1, ECPGst_normal, "move absolute 0 in $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 87 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 87 "cursor.pgc" strcpy(msg, "fetch 1"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname1, ECPGst_normal, "fetch 1 $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 90 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 90 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch :count"); count = 1; { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname1, ECPGst_normal, "fetch $0 $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 95 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 95 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "close"); { ECPGclose(__LINE__, 0, 1, "test1", 0, curname1, ECPGst_normal, "close $0", ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 99 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 99 "cursor.pgc" /* Dynamic cursorname test with INTO list in DECLARE stmt */ strcpy(msg, "declare"); ECPGset_var( 1, &( curname2 ), __LINE__);\ ECPGset_var( 2, ( t ), __LINE__);\ ECPGset_var( 3, &( id ), __LINE__);\ /* declare $0 no scroll cursor for select id , t from t1 */ #line 105 "cursor.pgc" strcpy(msg, "open"); { ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname2, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 108 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 108 "cursor.pgc" strcpy(msg, "fetch from"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname2, ECPGst_normal, "fetch from $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 111 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 111 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname2, ECPGst_normal, "fetch $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 115 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 115 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch 1 from"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname2, ECPGst_normal, "fetch 1 from $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 119 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 119 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch :count from"); count = 1; { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname2, ECPGst_normal, "fetch $0 from $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 124 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 124 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "move"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", 1, curname2, ECPGst_normal, "move absolute 0 $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 128 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 128 "cursor.pgc" strcpy(msg, "fetch 1"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname2, ECPGst_normal, "fetch 1 $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 131 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 131 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch :count"); count = 1; { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname2, ECPGst_normal, "fetch $0 $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 136 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 136 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "close"); { ECPGclose(__LINE__, 0, 1, "test1", 0, curname2, ECPGst_normal, "close $0", ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 140 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 140 "cursor.pgc" /* Dynamic cursorname test with PREPARED stmt */ strcpy(msg, "prepare"); { ECPGprepare(__LINE__, "test1", 0, "st_id1", stmt1); #line 145 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 145 "cursor.pgc" { ECPGprepare(__LINE__, "test2", 0, "st_id1", stmt1); #line 146 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 146 "cursor.pgc" strcpy(msg, "declare"); ECPGset_var( 4, &( curname3 ), __LINE__);\ /* declare $0 no scroll cursor for $1 */ #line 149 "cursor.pgc" ECPGset_var( 5, &( curname5 ), __LINE__);\ /* declare $0 no scroll cursor for $1 */ #line 150 "cursor.pgc" strcpy(msg, "open"); { ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname3, ECPGst_normal, "declare $0 no scroll cursor for $1", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 153 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 153 "cursor.pgc" { ECPGopen(__LINE__, 0, 1, "test2", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname5, ECPGst_normal, "declare $0 no scroll cursor for $1", ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char_variable,(ECPGprepared_statement("test2", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 154 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 154 "cursor.pgc" strcpy(msg, "fetch"); { ECPGfetch(__LINE__, 0, 1, "test2", 0, ECPGc_forward, "1", 0, curname5, ECPGst_normal, "fetch $0", ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 157 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 157 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch from"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname3, ECPGst_normal, "fetch from $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 161 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 161 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch 1 from"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname3, ECPGst_normal, "fetch 1 from $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 165 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 165 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch :count from"); count = 1; { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname3, ECPGst_normal, "fetch $0 from $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 170 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 170 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "move"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", 1, curname3, ECPGst_normal, "move absolute 0 $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 174 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 174 "cursor.pgc" strcpy(msg, "fetch 1"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname3, ECPGst_normal, "fetch 1 $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 177 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 177 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch :count"); count = 1; { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname3, ECPGst_normal, "fetch $0 $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 182 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 182 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "close"); { ECPGclose(__LINE__, 0, 1, "test1", 0, curname3, ECPGst_normal, "close $0", ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 186 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 186 "cursor.pgc" { ECPGclose(__LINE__, 0, 1, "test2", 0, curname5, ECPGst_normal, "close $0", ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 187 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 187 "cursor.pgc" strcpy(msg, "deallocate prepare"); { ECPGdeallocate(__LINE__, 0, "test1", "st_id1"); #line 190 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 190 "cursor.pgc" { ECPGdeallocate(__LINE__, 0, "test2", "st_id1"); #line 191 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 191 "cursor.pgc" /* Dynamic cursorname test with PREPARED stmt, cursor name in varchar */ curname4.len = strlen(CURNAME); strcpy(curname4.arr, CURNAME); strcpy(msg, "prepare"); { ECPGprepare(__LINE__, "test1", 0, "st_id2", stmt1); #line 200 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 200 "cursor.pgc" strcpy(msg, "declare"); ECPGset_var( 6, &( curname4 ), __LINE__);\ /* declare $0 no scroll cursor for $1 */ #line 203 "cursor.pgc" strcpy(msg, "open"); { ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname4.arr, ECPGst_normal, "declare $0 no scroll cursor for $1", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 206 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 206 "cursor.pgc" strcpy(msg, "fetch from"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname4.arr, ECPGst_normal, "fetch from $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 209 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 209 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname4.arr, ECPGst_normal, "fetch $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 213 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 213 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch 1 from"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname4.arr, ECPGst_normal, "fetch 1 from $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 217 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 217 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch :count from"); count = 1; { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname4.arr, ECPGst_normal, "fetch $0 from $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 222 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 222 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "move"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", 1, curname4.arr, ECPGst_normal, "move absolute 0 $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 226 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 226 "cursor.pgc" strcpy(msg, "fetch 1"); { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname4.arr, ECPGst_normal, "fetch 1 $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 229 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 229 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "fetch :count"); count = 1; { ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname4.arr, ECPGst_normal, "fetch $0 $0", ECPGt_int,&(count),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(id),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 234 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 234 "cursor.pgc" printf("%d %s\n", id, t); strcpy(msg, "close"); { ECPGclose(__LINE__, 0, 1, "test1", 0, curname4.arr, ECPGst_normal, "close $0", ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 238 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 238 "cursor.pgc" strcpy(msg, "deallocate prepare"); { ECPGdeallocate(__LINE__, 0, "test1", "st_id2"); #line 241 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 241 "cursor.pgc" /* End test */ strcpy(msg, "drop"); { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT); #line 246 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 246 "cursor.pgc" { ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT); #line 247 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 247 "cursor.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, "test1", "commit", 0, 0, 0, NULL); #line 250 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 250 "cursor.pgc" strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "ALL"); #line 253 "cursor.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 253 "cursor.pgc" return (0); }
int main(void) { #line 14 "test_informix.pgc" int i = 14 ; #line 14 "test_informix.pgc" #line 15 "test_informix.pgc" decimal j , m , n ; #line 15 "test_informix.pgc" #line 16 "test_informix.pgc" char c [ 10 ] ; #line 16 "test_informix.pgc" ECPGdebug(1, stderr); /* exec sql whenever sqlerror do dosqlprint ( ) ; */ #line 19 "test_informix.pgc" { ECPGconnect(__LINE__, 1, "ecpg1_regression" , NULL, NULL , NULL, 0); #line 21 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 21 "test_informix.pgc" if (sqlca.sqlcode != 0) exit(1); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table test ( i int primary key , j int , c text )", ECPGt_EOIT, ECPGt_EORT); #line 24 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 24 "test_informix.pgc" /* this INSERT works */ rsetnull(CDECIMALTYPE, (char *)&j); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j , c ) values ( 7 , $1 , 'test ' )", ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 28 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 28 "test_informix.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 29 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 29 "test_informix.pgc" /* this INSERT should fail because i is a unique column */ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j , c ) values ( 7 , 12 , 'a' )", ECPGt_EOIT, ECPGt_EORT); #line 32 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 32 "test_informix.pgc" printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback"); #line 34 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 34 "test_informix.pgc" { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into test ( i , j , c ) values ( $1 , 1 , 'a ' )", ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 36 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 36 "test_informix.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 37 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 37 "test_informix.pgc" /* this will fail (more than one row in subquery) */ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select i from test where j = ( select j from test )", ECPGt_EOIT, ECPGt_EORT); #line 40 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 40 "test_informix.pgc" { ECPGtrans(__LINE__, NULL, "rollback"); #line 41 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 41 "test_informix.pgc" /* this however should be ok */ { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select i from test where j = ( select j from test order by i limit 1 )", ECPGt_EOIT, ECPGt_EORT); #line 44 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 44 "test_informix.pgc" printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback"); #line 46 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 46 "test_informix.pgc" sqlca.sqlcode = 100; ECPGset_var( 0, &( i ), __LINE__);\ ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1 */ #line 49 "test_informix.pgc" printf ("%ld\n", sqlca.sqlcode); openit(); deccvint(0, &j); while (1) { { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward c", ECPGt_EOIT, ECPGt_int,&(i),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_string,(c),(long)10,(long)1,(10)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 57 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 57 "test_informix.pgc" if (sqlca.sqlcode == 100) break; else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode); if (risnull(CDECIMALTYPE, (char *)&j)) printf("%d NULL\n", i); else { int a; dectoint(&j, &a); printf("%d %d \"%s\"\n", i, a, c); } } deccvint(7, &j); deccvint(14, &m); decadd(&j, &m, &n); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "delete from test where i = $1 :: decimal", ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 75 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 75 "test_informix.pgc" printf("DELETE: %ld\n", sqlca.sqlcode); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select 1 from test where i = 14", ECPGt_EOIT, ECPGt_EORT); #line 78 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 78 "test_informix.pgc" printf("Exists: %ld\n", sqlca.sqlcode); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select 1 from test where i = 147", ECPGt_EOIT, ECPGt_EORT); #line 81 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 81 "test_informix.pgc" printf("Does not exist: %ld\n", sqlca.sqlcode); { ECPGtrans(__LINE__, NULL, "commit"); #line 84 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 84 "test_informix.pgc" { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT); #line 85 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 85 "test_informix.pgc" { ECPGtrans(__LINE__, NULL, "commit"); #line 86 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 86 "test_informix.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); #line 88 "test_informix.pgc" if (sqlca.sqlcode < 0) dosqlprint ( );} #line 88 "test_informix.pgc" return 0; }
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) { /* exec sql begin declare section */ #line 57 "sqlda.pgc" char * stmt1 = "SELECT * FROM t1" ; #line 58 "sqlda.pgc" char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ; #line 59 "sqlda.pgc" int rec ; #line 60 "sqlda.pgc" int id ; /* exec sql end declare section */ #line 61 "sqlda.pgc" char msg[128]; ECPGdebug(1, stderr); strcpy(msg, "connect"); { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "regress1", 0); #line 68 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 68 "sqlda.pgc" strcpy(msg, "set"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); #line 71 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 71 "sqlda.pgc" strcpy(msg, "create"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); #line 79 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 79 "sqlda.pgc" strcpy(msg, "insert"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT); #line 85 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 85 "sqlda.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); #line 88 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 88 "sqlda.pgc" /* SQLDA test for getting all records from a table */ outp_sqlda = NULL; strcpy(msg, "prepare"); { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1); #line 95 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 95 "sqlda.pgc" strcpy(msg, "declare"); ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */ #line 98 "sqlda.pgc" strcpy(msg, "open"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 101 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 101 "sqlda.pgc" /* exec sql whenever not found break ; */ #line 103 "sqlda.pgc" rec = 0; while (1) { strcpy(msg, "fetch"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 109 "sqlda.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 109 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 109 "sqlda.pgc" printf("FETCH RECORD %d\n", ++rec); dump_sqlda(outp_sqlda); } /* exec sql whenever not found continue ; */ #line 115 "sqlda.pgc" strcpy(msg, "close"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT); #line 118 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 118 "sqlda.pgc" strcpy(msg, "deallocate"); { ECPGdeallocate(__LINE__, 1, NULL, "st_id1"); #line 121 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 121 "sqlda.pgc" free(outp_sqlda); /* SQLDA test for getting all records from a table using the Informix-specific FETCH ... USING DESCRIPTOR */ outp_sqlda = NULL; strcpy(msg, "prepare"); { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1); #line 132 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 132 "sqlda.pgc" strcpy(msg, "declare"); ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */ #line 135 "sqlda.pgc" strcpy(msg, "open"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 138 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 138 "sqlda.pgc" /* exec sql whenever not found break ; */ #line 140 "sqlda.pgc" rec = 0; while (1) { strcpy(msg, "fetch"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 146 "sqlda.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 146 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 146 "sqlda.pgc" printf("FETCH RECORD %d\n", ++rec); dump_sqlda(outp_sqlda); } /* exec sql whenever not found continue ; */ #line 152 "sqlda.pgc" strcpy(msg, "close"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT); #line 155 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 155 "sqlda.pgc" strcpy(msg, "deallocate"); { ECPGdeallocate(__LINE__, 1, NULL, "st_id2"); #line 158 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 158 "sqlda.pgc" free(outp_sqlda); /* SQLDA test for getting one record using an input descriptor */ /* Input sqlda has to be built manually */ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t)); memset(inp_sqlda, 0, sizeof(sqlda_t)); inp_sqlda->sqld = 1; inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t)); memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t)); inp_sqlda->sqlvar[0].sqltype = SQLINT; inp_sqlda->sqlvar[0].sqldata = (char *)&id; printf("EXECUTE RECORD 4\n"); id = 4; outp_sqlda = NULL; strcpy(msg, "prepare"); { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2); #line 181 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 181 "sqlda.pgc" strcpy(msg, "execute"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_execute, "st_id3", ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 184 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 184 "sqlda.pgc" dump_sqlda(outp_sqlda); strcpy(msg, "deallocate"); { ECPGdeallocate(__LINE__, 1, NULL, "st_id3"); #line 189 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 189 "sqlda.pgc" free(inp_sqlda->sqlvar); free(inp_sqlda); free(outp_sqlda); /* SQLDA test for getting one record using an input descriptor * on a named connection */ { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "con2", 0); #line 199 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 199 "sqlda.pgc" /* Input sqlda has to be built manually */ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t)); memset(inp_sqlda, 0, sizeof(sqlda_t)); inp_sqlda->sqld = 1; inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t)); memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t)); inp_sqlda->sqlvar[0].sqltype = SQLINT; inp_sqlda->sqlvar[0].sqldata = (char *)&id; printf("EXECUTE RECORD 4\n"); id = 4; outp_sqlda = NULL; strcpy(msg, "prepare"); { ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2); #line 218 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 218 "sqlda.pgc" strcpy(msg, "execute"); { ECPGdo(__LINE__, 1, 1, "con2", 0, ECPGst_execute, "st_id4", ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 221 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 221 "sqlda.pgc" dump_sqlda(outp_sqlda); strcpy(msg, "commit"); { ECPGtrans(__LINE__, "con2", "commit"); #line 226 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 226 "sqlda.pgc" strcpy(msg, "deallocate"); { ECPGdeallocate(__LINE__, 1, NULL, "st_id4"); #line 229 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 229 "sqlda.pgc" free(inp_sqlda->sqlvar); free(inp_sqlda); free(outp_sqlda); strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "con2"); #line 236 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 236 "sqlda.pgc" /* End test */ strcpy(msg, "drop"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT); #line 241 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 241 "sqlda.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); #line 244 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 244 "sqlda.pgc" strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "CURRENT"); #line 247 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 247 "sqlda.pgc" return (0); }
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) { struct birthinfo { #line 23 "variable.pgc" long born ; #line 23 "variable.pgc" short age ; } ; #line 23 "variable.pgc" /* exec sql begin declare section */ #line 27 "variable.pgc" struct personal_struct { #line 25 "variable.pgc" struct varchar_1 { int len; char arr[ BUFFERSIZ ]; } name ; #line 26 "variable.pgc" struct birthinfo birth ; } personal , * p ; #line 30 "variable.pgc" struct personal_indicator { #line 28 "variable.pgc" int ind_name ; #line 29 "variable.pgc" struct birthinfo ind_birth ; } ind_personal , * i ; #line 31 "variable.pgc" ind ind_children ; struct t1 { #line 32 "variable.pgc" struct varchar_2 { int len; char arr[ BUFFERSIZ ]; } name ; } ; struct t2 { #line 32 "variable.pgc" struct varchar_3 { int len; char arr[ BUFFERSIZ ]; } name ; } ;/* exec sql end declare section */ #line 33 "variable.pgc" #line 35 "variable.pgc" char * married = NULL ; #line 35 "variable.pgc" #line 36 "variable.pgc" long ind_married ; #line 36 "variable.pgc" #line 37 "variable.pgc" ind children ; #line 37 "variable.pgc" char msg[128]; ECPGdebug(1, stderr); strcpy(msg, "connect"); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); #line 44 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 44 "variable.pgc" strcpy(msg, "set"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); #line 47 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 47 "variable.pgc" strcpy(msg, "create"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer )", ECPGt_EOIT, ECPGt_EORT); #line 50 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 50 "variable.pgc" strcpy(msg, "insert"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 )", ECPGt_EOIT, ECPGt_EORT); #line 53 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 53 "variable.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 )", ECPGt_EOIT, ECPGt_EORT); #line 54 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 54 "variable.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , age ) values ( 'Child 1' , 16 )", ECPGt_EOIT, ECPGt_EORT); #line 55 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 55 "variable.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , age ) values ( 'Child 2' , 14 )", ECPGt_EOIT, ECPGt_EORT); #line 56 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 56 "variable.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , age ) values ( 'Child 3' , 9 )", ECPGt_EOIT, ECPGt_EORT); #line 57 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 57 "variable.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL); #line 60 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 60 "variable.pgc" strcpy(msg, "open"); { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "cur", ECPGst_normal, "declare cur no scroll cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT); #line 63 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 63 "variable.pgc" /* exec sql whenever not found break ; */ #line 65 "variable.pgc" p=&personal; i=&ind_personal; memset(i, 0, sizeof(ind_personal)); while (1) { strcpy(msg, "fetch"); { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "cur", ECPGst_normal, "fetch cur", ECPGt_EOIT, ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)1,sizeof(struct varchar_1), ECPGt_int,&(i->ind_name),(long)1,(long)1,sizeof(int), ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof(long), ECPGt_long,&(i->ind_birth.born),(long)1,(long)1,sizeof(long), ECPGt_short,&(p->birth.age),(long)1,(long)1,sizeof(short), ECPGt_short,&(i->ind_birth.age),(long)1,(long)1,sizeof(short), ECPGt_char,&(married),(long)0,(long)1,(1)*sizeof(char), ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long), ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int), ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT); #line 72 "variable.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 72 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 72 "variable.pgc" printf("%8.8s", personal.name.arr); if (i->ind_birth.born >= 0) printf(", born %ld", personal.birth.born); if (i->ind_birth.age >= 0) printf(", age = %d", personal.birth.age); if (ind_married >= 0) printf(", married %s", married); if (ind_children.smallint >= 0) printf(", children = %d", children.integer); putchar('\n'); free(married); married = NULL; } strcpy(msg, "close"); { ECPGclose(__LINE__, 0, 1, NULL, 0, "cur", ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT); #line 89 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 89 "variable.pgc" strcpy(msg, "drop"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table family", ECPGt_EOIT, ECPGt_EORT); #line 92 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 92 "variable.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL); #line 95 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 95 "variable.pgc" strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "CURRENT"); #line 98 "variable.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 98 "variable.pgc" return (0); }
int main() { #ifndef WIN32 pthread_t *threads; #else HANDLE *threads; #endif int n; /* exec sql begin declare section */ #line 38 "thread.pgc" int l_rows ; /* exec sql end declare section */ #line 39 "thread.pgc" /* Do not switch on debug output for regression tests. The threads get executed in * more or less random order */ /* ECPGdebug(1, stderr); */ /* setup test_thread table */ { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } #line 46 "thread.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test_thread", ECPGt_EOIT, ECPGt_EORT);} #line 47 "thread.pgc" /* DROP might fail */ { ECPGtrans(__LINE__, NULL, "commit");} #line 48 "thread.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test_thread ( tstamp timestamp not null default cast ( timeofday ( ) as timestamp ) , thread text not null , iteration integer not null , primary key ( thread , iteration ) )", ECPGt_EOIT, ECPGt_EORT);} #line 53 "thread.pgc" { ECPGtrans(__LINE__, NULL, "commit");} #line 54 "thread.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 55 "thread.pgc" /* create, and start, threads */ threads = calloc(nthreads, sizeof(threads[0])); if( threads == NULL ) { fprintf(stderr, "Cannot alloc memory\n"); return( 1 ); } for( n = 0; n < nthreads; n++ ) { #ifndef WIN32 pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1)); #else threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread, (void *) (n + 1), 0, NULL); #endif } /* wait for thread completion */ #ifndef WIN32 for( n = 0; n < nthreads; n++ ) { pthread_join(threads[n], NULL); } #else WaitForMultipleObjects(nthreads, threads, TRUE, INFINITE); #endif free(threads); /* and check results */ { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } #line 85 "thread.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from test_thread", ECPGt_EOIT, ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 86 "thread.pgc" { ECPGtrans(__LINE__, NULL, "commit");} #line 87 "thread.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 88 "thread.pgc" if( l_rows == (nthreads * iterations) ) printf("Success.\n"); else printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows); 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 ); }
int main (void) { /* exec sql begin declare section */ #line 15 "describe.pgc" char * stmt1 = "SELECT id, t FROM descr_t1" ; #line 16 "describe.pgc" char * stmt2 = "SELECT id, t FROM descr_t1 WHERE id = -1" ; #line 17 "describe.pgc" int i , count1 , count2 ; #line 18 "describe.pgc" char field_name1 [ 30 ] = "not set" ; #line 19 "describe.pgc" char field_name2 [ 30 ] = "not set" ; /* exec sql end declare section */ #line 20 "describe.pgc" char msg[128]; ECPGdebug(1, stderr); strcpy(msg, "connect"); { ECPGconnect(__LINE__, 1, "ecpg1_regression" , NULL, NULL , NULL, 0); #line 27 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 27 "describe.pgc" strcpy(msg, "set"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); #line 30 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 30 "describe.pgc" strcpy(msg, "create"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table descr_t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT); #line 33 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 33 "describe.pgc" strcpy(msg, "insert"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT); #line 36 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 36 "describe.pgc" { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT); #line 37 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 37 "describe.pgc" { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT); #line 38 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 38 "describe.pgc" { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT); #line 39 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 39 "describe.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); #line 42 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 42 "describe.pgc" /* * Test DESCRIBE with a query producing tuples. * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in * Informix-compat mode. */ strcpy(msg, "allocate"); ECPGallocate_desc(__LINE__, "desc1"); #line 51 "describe.pgc" if (sqlca.sqlcode < 0) exit (1); #line 51 "describe.pgc" ECPGallocate_desc(__LINE__, "desc2"); #line 52 "describe.pgc" if (sqlca.sqlcode < 0) exit (1); #line 52 "describe.pgc" strcpy(msg, "prepare"); { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1); #line 55 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 55 "describe.pgc" sqlda1 = sqlda2 = sqlda3 = NULL; strcpy(msg, "describe"); { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1", ECPGt_descriptor, "desc1", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 60 "describe.pgc" { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1", ECPGt_descriptor, "desc2", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 61 "describe.pgc" { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1", ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 63 "describe.pgc" { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1", ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 64 "describe.pgc" { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1", ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 65 "describe.pgc" if (sqlda1 == NULL) { printf("sqlda1 NULL\n"); exit(1); } if (sqlda2 == NULL) { printf("sqlda2 NULL\n"); exit(1); } if (sqlda3 == NULL) { printf("sqlda3 NULL\n"); exit(1); } strcpy(msg, "get descriptor"); { ECPGget_desc_header(__LINE__, "desc1", &(count1)); #line 86 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 86 "describe.pgc" { ECPGget_desc_header(__LINE__, "desc1", &(count2)); #line 87 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 87 "describe.pgc" if (count1 != count2) { printf("count1 (%d) != count2 (%d)\n", count1, count2); exit(1); } if (count1 != sqlda1->sqld) { printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld); exit(1); } if (count1 != sqlda2->sqld) { printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld); exit(1); } if (count1 != sqlda3->sqld) { printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld); exit(1); } for (i = 1; i <= count1; i++) { { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name, ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT); #line 115 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 115 "describe.pgc" { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name, ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT); #line 116 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 116 "describe.pgc" printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t" "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n", i, field_name1, field_name2, sqlda1->sqlvar[i-1].sqlname, sqlda2->sqlvar[i-1].sqlname, sqlda3->sqlvar[i-1].sqlname); } strcpy(msg, "deallocate"); ECPGdeallocate_desc(__LINE__, "desc1"); #line 126 "describe.pgc" if (sqlca.sqlcode < 0) exit (1); #line 126 "describe.pgc" ECPGdeallocate_desc(__LINE__, "desc2"); #line 127 "describe.pgc" if (sqlca.sqlcode < 0) exit (1); #line 127 "describe.pgc" free(sqlda1); free(sqlda2); free(sqlda3); { ECPGdeallocate(__LINE__, 1, NULL, "st_id1"); #line 132 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 132 "describe.pgc" /* Test DESCRIBE with a query not producing tuples */ strcpy(msg, "allocate"); ECPGallocate_desc(__LINE__, "desc1"); #line 137 "describe.pgc" if (sqlca.sqlcode < 0) exit (1); #line 137 "describe.pgc" ECPGallocate_desc(__LINE__, "desc2"); #line 138 "describe.pgc" if (sqlca.sqlcode < 0) exit (1); #line 138 "describe.pgc" strcpy(msg, "prepare"); { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2); #line 141 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 141 "describe.pgc" sqlda1 = sqlda2 = sqlda3 = NULL; strcpy(msg, "describe"); { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2", ECPGt_descriptor, "desc1", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 146 "describe.pgc" { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2", ECPGt_descriptor, "desc2", 1L, 1L, 1L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 147 "describe.pgc" { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2", ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 149 "describe.pgc" { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2", ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 150 "describe.pgc" { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2", ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 151 "describe.pgc" if (sqlda1 == NULL || sqlda2 == NULL || sqlda3 == NULL) exit(1); strcpy(msg, "get descriptor"); { ECPGget_desc_header(__LINE__, "desc1", &(count1)); #line 157 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 157 "describe.pgc" { ECPGget_desc_header(__LINE__, "desc1", &(count2)); #line 158 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 158 "describe.pgc" if (!( count1 == count2 && count1 == sqlda1->sqld && count1 == sqlda2->sqld && count1 == sqlda3->sqld)) exit(1); for (i = 1; i <= count1; i++) { { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name, ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT); #line 168 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 168 "describe.pgc" { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name, ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT); #line 169 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 169 "describe.pgc" printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t" "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n", i, field_name1, field_name2, sqlda1->sqlvar[i-1].sqlname, sqlda2->sqlvar[i-1].sqlname, sqlda3->sqlvar[i-1].sqlname); } strcpy(msg, "deallocate"); ECPGdeallocate_desc(__LINE__, "desc1"); #line 179 "describe.pgc" if (sqlca.sqlcode < 0) exit (1); #line 179 "describe.pgc" ECPGdeallocate_desc(__LINE__, "desc2"); #line 180 "describe.pgc" if (sqlca.sqlcode < 0) exit (1); #line 180 "describe.pgc" free(sqlda1); free(sqlda2); free(sqlda3); { ECPGdeallocate(__LINE__, 1, NULL, "st_id2"); #line 185 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 185 "describe.pgc" /* End test */ strcpy(msg, "drop"); { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table descr_t1", ECPGt_EOIT, ECPGt_EORT); #line 190 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 190 "describe.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); #line 193 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 193 "describe.pgc" strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "CURRENT"); #line 196 "describe.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 196 "describe.pgc" return 0; }
int main (void) { /* exec sql begin declare section */ #line 22 "binary.pgc" struct TBempl empl ; #line 23 "binary.pgc" char * pointer = NULL ; #line 24 "binary.pgc" char * data = "\\001\\155\\000\\212" ; /* exec sql end declare section */ #line 25 "binary.pgc" int i; ECPGdebug (1, stderr); empl.idnum = 1; { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); #line 31 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 31 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set bytea_output = escape", ECPGt_EOIT, ECPGt_EORT); #line 32 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 32 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , byte bytea )", ECPGt_EOIT, ECPGt_EORT); #line 34 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 34 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into empl values ( 1 , 'first user' , 320 , $1 )", ECPGt_char,&(data),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 35 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 35 "binary.pgc" ECPGset_var( 0, &( empl.idnum ), __LINE__);\ /* declare C cursor for select name , accs , byte from empl where idnum = $1 */ #line 36 "binary.pgc" if (sqlca.sqlcode < 0) exit (1); #line 36 "binary.pgc" #line 36 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 37 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 37 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 38 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 38 "binary.pgc" printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT); #line 41 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 41 "binary.pgc" memset(empl.name, 0, 21L); ECPGset_var( 1, &( empl.idnum ), __LINE__);\ /* declare B binary cursor for select name , accs , byte from empl where idnum = $1 */ #line 44 "binary.pgc" if (sqlca.sqlcode < 0) exit (1); #line 44 "binary.pgc" #line 44 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 45 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 45 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch B", ECPGt_EOIT, ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 46 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 46 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close B", ECPGt_EOIT, ECPGt_EORT); #line 47 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 47 "binary.pgc" /* do not print a.accs because big/little endian will have different outputs here */ printf ("name=%s, byte=", empl.name); for (i=0; i<4; i++) printf("(%o)", (unsigned char)empl.byte[i]); printf("\n"); ECPGset_var( 2, &( empl.idnum ), __LINE__);\ /* declare A binary cursor for select byte from empl where idnum = $1 */ #line 55 "binary.pgc" if (sqlca.sqlcode < 0) exit (1); #line 55 "binary.pgc" #line 55 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 56 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 56 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch A", ECPGt_EOIT, ECPGt_char,&(pointer),(long)0,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 57 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 57 "binary.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close A", ECPGt_EOIT, ECPGt_EORT); #line 58 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 58 "binary.pgc" if (pointer) { printf ("pointer="); for (i=0; i<4; i++) printf("(%o)", (unsigned char)pointer[i]); printf("\n"); free(pointer); } { ECPGdisconnect(__LINE__, "CURRENT"); #line 68 "binary.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 68 "binary.pgc" exit (0); }
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) { MYTYPE *myvar; MYNULLTYPE *mynullvar; char msg[128]; ECPGdebug(1, stderr); strcpy(msg, "connect"); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); #line 75 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 75 "outofscope.pgc" strcpy(msg, "set"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); #line 78 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 78 "outofscope.pgc" strcpy(msg, "create"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); #line 81 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 81 "outofscope.pgc" strcpy(msg, "insert"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT); #line 84 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 84 "outofscope.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT); #line 85 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 85 "outofscope.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT); #line 86 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 86 "outofscope.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); #line 89 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 89 "outofscope.pgc" /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */ get_var1(&myvar, &mynullvar); open_cur1(); /* exec sql whenever not found break ; */ #line 96 "outofscope.pgc" while (1) { memset(myvar, 0, sizeof(MYTYPE)); get_record1(); if (sqlca.sqlcode == ECPG_NOT_FOUND) break; printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n", myvar->id, mynullvar->id ? " (NULL)" : "", myvar->t, mynullvar->t ? " (NULL)" : "", myvar->d1, mynullvar->d1 ? " (NULL)" : "", myvar->d2, mynullvar->d2 ? " (NULL)" : "", myvar->c, mynullvar->c ? " (NULL)" : ""); } close_cur1(); free(myvar); free(mynullvar); strcpy(msg, "drop"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT); #line 118 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 118 "outofscope.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); #line 121 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 121 "outofscope.pgc" strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "CURRENT"); #line 124 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 124 "outofscope.pgc" return (0); }
int main() { /* exec sql begin declare section */ #line 9 "indicators.pgc" int intvar = 5 ; #line 10 "indicators.pgc" int nullind = - 1 ; /* exec sql end declare section */ #line 11 "indicators.pgc" ECPGdebug(1,stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } #line 15 "indicators.pgc" { ECPGsetcommit(__LINE__, "off", NULL);} #line 16 "indicators.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table indicator_test ( \"id\" int primary key , \"str\" text not null , val int null )", ECPGt_EOIT, ECPGt_EORT);} #line 21 "indicators.pgc" { ECPGtrans(__LINE__, NULL, "commit work");} #line 22 "indicators.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 1 , 'Hello' , 0 )", ECPGt_EOIT, ECPGt_EORT);} #line 24 "indicators.pgc" /* use indicator in insert */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 2 , 'Hi there' , $1 )", ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);} #line 27 "indicators.pgc" nullind = 0; { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 3 , 'Good evening' , $1 )", ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);} #line 29 "indicators.pgc" { ECPGtrans(__LINE__, NULL, "commit work");} #line 30 "indicators.pgc" /* use indicators to get information about selects */ { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 1", ECPGt_EOIT, ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 33 "indicators.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 2", ECPGt_EOIT, ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);} #line 34 "indicators.pgc" printf("intvar: %d, nullind: %d\n", intvar, nullind); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 3", ECPGt_EOIT, ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);} #line 36 "indicators.pgc" printf("intvar: %d, nullind: %d\n", intvar, nullind); /* use indicators for update */ intvar = 5; nullind = -1; { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update indicator_test set val = $1 where id = 1", ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);} #line 41 "indicators.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 1", ECPGt_EOIT, ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);} #line 42 "indicators.pgc" printf("intvar: %d, nullind: %d\n", intvar, nullind); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table indicator_test", ECPGt_EOIT, ECPGt_EORT);} #line 45 "indicators.pgc" { ECPGtrans(__LINE__, NULL, "commit work");} #line 46 "indicators.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 48 "indicators.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; }
int main (void) { /* exec sql begin declare section */ #line 59 "sqlda.pgc" char * stmt1 = "SELECT * FROM t1" ; #line 60 "sqlda.pgc" char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ; #line 61 "sqlda.pgc" int rec ; #line 62 "sqlda.pgc" int id ; /* exec sql end declare section */ #line 63 "sqlda.pgc" char msg[128]; ECPGdebug(1, stderr); strcpy(msg, "connect"); { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "regress1", 0); #line 70 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 70 "sqlda.pgc" strcpy(msg, "set"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); #line 73 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 73 "sqlda.pgc" strcpy(msg, "create"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); #line 81 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 81 "sqlda.pgc" strcpy(msg, "insert"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT); #line 87 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 87 "sqlda.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); #line 90 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 90 "sqlda.pgc" /* SQLDA test for getting all records from a table */ outp_sqlda = NULL; strcpy(msg, "prepare"); { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1); #line 97 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 97 "sqlda.pgc" strcpy(msg, "declare"); /* declare mycur1 cursor for $1 */ #line 100 "sqlda.pgc" strcpy(msg, "open"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 103 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 103 "sqlda.pgc" /* exec sql whenever not found break ; */ #line 105 "sqlda.pgc" rec = 0; while (1) { strcpy(msg, "fetch"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 111 "sqlda.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 111 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 111 "sqlda.pgc" printf("FETCH RECORD %d\n", ++rec); dump_sqlda(outp_sqlda); } /* exec sql whenever not found continue ; */ #line 117 "sqlda.pgc" strcpy(msg, "close"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT); #line 120 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 120 "sqlda.pgc" strcpy(msg, "deallocate"); { ECPGdeallocate(__LINE__, 0, NULL, "st_id1"); #line 123 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 123 "sqlda.pgc" free(outp_sqlda); /* SQLDA test for getting ALL records into the sqlda list */ outp_sqlda = NULL; strcpy(msg, "prepare"); { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1); #line 132 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 132 "sqlda.pgc" strcpy(msg, "declare"); /* declare mycur2 cursor for $1 */ #line 135 "sqlda.pgc" strcpy(msg, "open"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 138 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 138 "sqlda.pgc" strcpy(msg, "fetch"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 141 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 141 "sqlda.pgc" outp_sqlda1 = outp_sqlda; rec = 0; while (outp_sqlda1) { sqlda_t *ptr; printf("FETCH RECORD %d\n", ++rec); dump_sqlda(outp_sqlda1); ptr = outp_sqlda1; outp_sqlda1 = outp_sqlda1->desc_next; free(ptr); } strcpy(msg, "close"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT); #line 157 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 157 "sqlda.pgc" strcpy(msg, "deallocate"); { ECPGdeallocate(__LINE__, 0, NULL, "st_id2"); #line 160 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 160 "sqlda.pgc" /* SQLDA test for getting one record using an input descriptor */ /* * Input sqlda has to be built manually * sqlda_t contains 1 sqlvar_t structure already. */ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t)); memset(inp_sqlda, 0, sizeof(sqlda_t)); inp_sqlda->sqln = 1; inp_sqlda->sqlvar[0].sqltype = ECPGt_int; inp_sqlda->sqlvar[0].sqldata = (char *)&id; printf("EXECUTE RECORD 4\n"); id = 4; outp_sqlda = NULL; strcpy(msg, "prepare"); { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2); #line 182 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 182 "sqlda.pgc" strcpy(msg, "execute"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "st_id3", ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 185 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 185 "sqlda.pgc" dump_sqlda(outp_sqlda); strcpy(msg, "deallocate"); { ECPGdeallocate(__LINE__, 0, NULL, "st_id3"); #line 190 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 190 "sqlda.pgc" free(inp_sqlda); free(outp_sqlda); /* SQLDA test for getting one record using an input descriptor * on a named connection */ { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con2", 0); #line 199 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 199 "sqlda.pgc" /* * Input sqlda has to be built manually * sqlda_t contains 1 sqlvar_t structure already. */ inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t)); memset(inp_sqlda, 0, sizeof(sqlda_t)); inp_sqlda->sqln = 1; inp_sqlda->sqlvar[0].sqltype = ECPGt_int; inp_sqlda->sqlvar[0].sqldata = (char *)&id; printf("EXECUTE RECORD 4\n"); id = 4; outp_sqlda = NULL; strcpy(msg, "prepare"); { ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2); #line 219 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 219 "sqlda.pgc" strcpy(msg, "execute"); { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "st_id4", ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); #line 222 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 222 "sqlda.pgc" dump_sqlda(outp_sqlda); strcpy(msg, "commit"); { ECPGtrans(__LINE__, "con2", "commit"); #line 227 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 227 "sqlda.pgc" strcpy(msg, "deallocate"); { ECPGdeallocate(__LINE__, 0, NULL, "st_id4"); #line 230 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 230 "sqlda.pgc" free(inp_sqlda); free(outp_sqlda); strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "con2"); #line 236 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 236 "sqlda.pgc" /* End test */ strcpy(msg, "drop"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT); #line 241 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 241 "sqlda.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); #line 244 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 244 "sqlda.pgc" strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "CURRENT"); #line 247 "sqlda.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 247 "sqlda.pgc" return 0; }
int main(void) { /* exec sql begin declare section */ #line 16 "test5.pgc" char db [ 200 ] ; #line 17 "test5.pgc" char id [ 200 ] ; #line 18 "test5.pgc" char * user = "******" ; /* exec sql end declare section */ #line 19 "test5.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); } #line 23 "test5.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecpg_user2 encrypted password 'insecure'", ECPGt_EOIT, ECPGt_EORT); } #line 24 "test5.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecpg_user1 encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT); } #line 25 "test5.pgc" { ECPGtrans(__LINE__, NULL, "commit"); } #line 26 "test5.pgc" { ECPGdisconnect(__LINE__, "CURRENT"); } #line 27 "test5.pgc" /* <-- "main" not specified */ strcpy(db, "ecpg2_regression"); strcpy(id, "main"); { ECPGconnect(__LINE__, 0, db , NULL, NULL , id, 0); } #line 31 "test5.pgc" { ECPGdisconnect(__LINE__, id); } #line 32 "test5.pgc" { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); } #line 34 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 35 "test5.pgc" { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); } #line 37 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 38 "test5.pgc" { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); } #line 40 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 41 "test5.pgc" { ECPGconnect(__LINE__, 0, "" , "regress_ecpg_user2" , "insecure" , "main", 0); } #line 43 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 44 "test5.pgc" { ECPGconnect(__LINE__, 0, "ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); } #line 46 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 47 "test5.pgc" { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); } #line 49 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 50 "test5.pgc" { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); } #line 52 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 53 "test5.pgc" { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , user , "connectpw" , "main", 0); } #line 55 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 56 "test5.pgc" { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression?connect_timeout=14 & client_encoding=latin1" , "regress_ecpg_user1" , "connectpw" , "main", 0); } #line 58 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 59 "test5.pgc" { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , "main", 0); } #line 61 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 62 "test5.pgc" { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "regress_ecpg_user2" , "insecure" , "main", 0); } #line 64 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 65 "test5.pgc" /* connect twice */ { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); } #line 68 "test5.pgc" { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); } #line 69 "test5.pgc" { ECPGdisconnect(__LINE__, "main"); } #line 70 "test5.pgc" /* not connected */ { ECPGdisconnect(__LINE__, "nonexistant"); } #line 73 "test5.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() { /* exec sql whenever sql_warning do warn ( ) ; */ #line 18 "char_array.pgc" /* exec sql whenever sqlerror stop ; */ #line 19 "char_array.pgc" const char *ppppp = "XXXXX"; int loopcount; /* exec sql begin declare section */ #line 24 "char_array.pgc" char shortstr [ 5 ] ; #line 25 "char_array.pgc" char bigstr [ 11 ] ; #line 26 "char_array.pgc" short shstr_ind = 0 ; #line 27 "char_array.pgc" short bigstr_ind = 0 ; /* exec sql end declare section */ #line 28 "char_array.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 3, "ecpg1_regression" , NULL, NULL , NULL, 0); #line 31 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 31 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 31 "char_array.pgc" { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "create table strdbase ( strval varchar ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); #line 33 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 33 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 33 "char_array.pgc" { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "insert into strdbase values ( '' )", ECPGt_EOIT, ECPGt_EORT); #line 34 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 34 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 34 "char_array.pgc" { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "insert into strdbase values ( 'AB' )", ECPGt_EOIT, ECPGt_EORT); #line 35 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 35 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 35 "char_array.pgc" { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "insert into strdbase values ( 'ABCD' )", ECPGt_EOIT, ECPGt_EORT); #line 36 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 36 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 36 "char_array.pgc" { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "insert into strdbase values ( 'ABCDE' )", ECPGt_EOIT, ECPGt_EORT); #line 37 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 37 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 37 "char_array.pgc" { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "insert into strdbase values ( 'ABCDEF' )", ECPGt_EOIT, ECPGt_EORT); #line 38 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 38 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 38 "char_array.pgc" { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "insert into strdbase values ( 'ABCDEFGHIJ' )", ECPGt_EOIT, ECPGt_EORT); #line 39 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 39 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 39 "char_array.pgc" /* declare C cursor for select strval , strval from strdbase */ #line 41 "char_array.pgc" { ECPGopen("C", NULL, __LINE__, 3, 1, NULL, 0, ECPGst_normal, "declare C cursor for select strval , strval from strdbase", ECPGt_EOIT, ECPGt_EORT); #line 42 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 42 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 42 "char_array.pgc" /* exec sql whenever not found break ; */ #line 44 "char_array.pgc" printf("Full Str. : Short Ind.\n"); for (loopcount = 0; loopcount < 100; loopcount++) { strncpy(shortstr, ppppp, sizeof shortstr); memset(bigstr, 0, sizeof bigstr); { ECPGfetch("C", __LINE__, 3, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, ECPGt_char,(bigstr),(long)11,(long)1,(11)*sizeof(char), ECPGt_short,&(bigstr_ind),(long)1,(long)1,sizeof(short), ECPGt_char,(shortstr),(long)5,(long)1,(5)*sizeof(char), ECPGt_short,&(shstr_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT); #line 50 "char_array.pgc" if (sqlca.sqlcode == ECPG_NOT_FOUND) break; #line 50 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 50 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 50 "char_array.pgc" printf("\"%s\": \"%s\" %d\n", bigstr, shortstr, shstr_ind); } { ECPGclose("C", __LINE__, 3, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT); #line 54 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 54 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 54 "char_array.pgc" { ECPGdo(__LINE__, 3, 1, NULL, 0, ECPGst_normal, "drop table strdbase", ECPGt_EOIT, ECPGt_EORT); #line 55 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 55 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 55 "char_array.pgc" printf("\nGOOD-BYE!!\n\n"); { ECPGtrans(__LINE__, NULL, "commit work"); #line 59 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 59 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 59 "char_array.pgc" { ECPGdisconnect(__LINE__, "ALL"); #line 61 "char_array.pgc" if (sqlca.sqlwarn[0] == 'W') warn ( ); #line 61 "char_array.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 61 "char_array.pgc" return 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 16 "test1.pgc" char db [ 200 ] ; #line 17 "test1.pgc" char pw [ 200 ] ; /* exec sql end declare section */ #line 18 "test1.pgc" ECPGdebug(1, stderr); { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); } #line 22 "test1.pgc" { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecpg_user1 encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);} #line 23 "test1.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 24 "test1.pgc" /* <-- "main" not specified */ { ECPGconnect(__LINE__, 0, "ecpg2_regression@localhost" , NULL, NULL , "main", 0); } #line 26 "test1.pgc" { ECPGdisconnect(__LINE__, "main");} #line 27 "test1.pgc" { ECPGconnect(__LINE__, 0, "@localhost" , "regress_ecpg_user2" , NULL , "main", 0); } #line 29 "test1.pgc" { ECPGdisconnect(__LINE__, "main");} #line 30 "test1.pgc" /* exec sql connect to :@TEMP_PORT@ as main user regress_ecpg_user2; exec sql disconnect main; */ { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , NULL, 0); } #line 35 "test1.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 36 "test1.pgc" { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/" , "regress_ecpg_user2" , NULL , NULL, 0); } #line 38 "test1.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 39 "test1.pgc" strcpy(pw, "connectpw"); strcpy(db, "tcp:postgresql://localhost/ecpg2_regression"); { ECPGconnect(__LINE__, 0, db , "regress_ecpg_user1" , pw , NULL, 0); } #line 43 "test1.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 44 "test1.pgc" { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , NULL, 0); } #line 46 "test1.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 47 "test1.pgc" { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression?connect_timeout=14" , "regress_ecpg_user1" , NULL , NULL, 0); } #line 49 "test1.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 50 "test1.pgc" /* wrong db */ { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/nonexistant" , "regress_ecpg_user1" , "connectpw" , NULL, 0); } #line 53 "test1.pgc" { ECPGdisconnect(__LINE__, "CURRENT");} #line 54 "test1.pgc" /* wrong port */ { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:20/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" , NULL, 0); } #line 57 "test1.pgc" /* no disconnect necessary */ /* wrong password */ { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "wrongpw" , NULL, 0); } #line 61 "test1.pgc" /* no disconnect necessary */ 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() { /* exec sql begin declare section */ #line 9 "code100.pgc" int index ; /* exec sql end declare section */ #line 10 "code100.pgc" ECPGdebug(1,stderr); { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } #line 15 "code100.pgc" if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( \"index\" numeric ( 3 ) primary key , \"payload\" int4 not null )", ECPGt_EOIT, ECPGt_EORT);} #line 20 "code100.pgc" if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); { ECPGtrans(__LINE__, NULL, "commit work");} #line 22 "code100.pgc" if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); for (index=0;index<10;++index) { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( payload , index ) values ( 0 , $1 )", ECPGt_int,&(index),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 28 "code100.pgc" if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); } { ECPGtrans(__LINE__, NULL, "commit work");} #line 31 "code100.pgc" if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update test set payload = payload + 1 where index = - 1", ECPGt_EOIT, ECPGt_EORT);} #line 35 "code100.pgc" if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from test where index = - 1", ECPGt_EOIT, ECPGt_EORT);} #line 38 "code100.pgc" if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( select * from test where index = - 1 )", ECPGt_EOIT, ECPGt_EORT);} #line 41 "code100.pgc" if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);} #line 44 "code100.pgc" if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); { ECPGtrans(__LINE__, NULL, "commit work");} #line 46 "code100.pgc" if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); { ECPGdisconnect(__LINE__, "CURRENT");} #line 49 "code100.pgc" if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); 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); }
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; }