Exemplo n.º 1
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() {

  /* 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;
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
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, "ecpg1_regression" , 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, (desc1), 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__, (desc1), 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"

	{ ECPGopen("c1", "foo2", __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"


	{ ECPGfetch("c1", __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);

	{ ECPGclose("c1", __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"

	{ ECPGopen("c2", "foo3", __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"


	{ ECPGfetch("c2", __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);

	{ ECPGclose("c2", __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__, (desc1));
#line 86 "desc.pgc"

if (sqlca.sqlcode < 0) sqlprint();
#line 86 "desc.pgc"


	return 0;
}
Exemplo n.º 5
0
int main(void)
{
/* exec sql begin declare section */
		 
		

#line 11 "cursor-ra-fetch.pgc"
 int id [ 8 ] , i ;
 
#line 12 "cursor-ra-fetch.pgc"
  struct varchar_1  { int len; char arr[ 50 ]; }  t [ 8 ] ;
/* exec sql end declare section */
#line 13 "cursor-ra-fetch.pgc"

	int	quit_loop;

	ECPGdebug(1, stderr);

	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 18 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 18 "cursor-ra-fetch.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
#line 20 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 20 "cursor-ra-fetch.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ) , ( 'd' ) , ( 'e' ) , ( 'f' ) , ( 'g' ) , ( 'h' ) , ( 'i' ) , ( 'j' ) , ( 'k' ) , ( 'l' ) , ( 'm' ) , ( 'n' ) , ( 'o' ) , ( 'p' ) , ( 'q' ) , ( 'r' ) , ( 's' ) , ( 't' ) , ( 'u' ) , ( 'v' ) , ( 'w' ) , ( 'x' ) , ( 'y' ) , ( 'z' )", ECPGt_EOIT, ECPGt_EORT);
#line 25 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 25 "cursor-ra-fetch.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
#line 26 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 26 "cursor-ra-fetch.pgc"


	/* declare scroll_cur scroll cursor for select id , t from t1 order by id */
#line 28 "cursor-ra-fetch.pgc"

	/* declare scroll_cur4 scroll cursor for select id , t from t1 order by id */
#line 29 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH ABSOLUTE N with an interval of 4 using positive positions.
	 * Readahead is 8 so caching is in effect.
	 */

	printf("test scroll_cur for move absolute n (every 4th tuple forward, positive positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 38 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 38 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	for (i = 1; i < 33; i += 4)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 44 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 44 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
		else
			printf("\trow %d does not exist\n", i);
	}

	printf("\ntest scroll_cur for move absolute n (every 4th tuple backward, positive positions)\n");

	for (i = 33; i >= 0; i -= 4)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 56 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 56 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
		else
			printf("\trow %d does not exist\n", i);
	}

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 64 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 64 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH ABSOLUTE N with an interval of 4 using negative positions.
	 * Readahead is 8 so caching is in effect.
	 */

	printf("\ntest scroll_cur for move absolute n (every 4th tuple backward, negative positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 73 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 73 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	for (i = -1; i > -33; i -= 4)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 79 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 79 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
		else
			printf("\trow %d does not exist\n", i);
	}

	printf("\ntest scroll_cur for move absolute n (every 4th tuple forward, negative positions)\n");

	for (i = -33; i <= 0; i += 4)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 91 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 91 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
		else
			printf("\trow %d does not exist\n", i);
	}

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 99 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 99 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH RELATIVE +/- 4 using positive positions
	 * readahead is 8, so caching is in effect
	 */

	printf("\ntest scroll_cur for fetch relative 4 (positive positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 108 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 108 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	quit_loop = 0;
	while (!quit_loop)
	{
		for (i = 0; i < 8; i++)
			id[i] = 0, t[i].arr[0] = '\0';
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "4", 0, "scroll_cur", ECPGst_normal, "fetch relative 4 in scroll_cur", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 117 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 117 "cursor-ra-fetch.pgc"

		if (sqlca.sqlcode < 0)
			printf("fetch relative 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
		else
			printf("fetch relative 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
		for (i = 0; i < sqlca.sqlerrd[2]; i++)
			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	printf("\ntest scroll_cur for fetch relative -4 (positive positions)\n");

	quit_loop = 0;
	while (!quit_loop)
	{
		for (i = 0; i < 8; i++)
			id[i] = 0, t[i].arr[0] = '\0';
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch relative - 4 in scroll_cur", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 134 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 134 "cursor-ra-fetch.pgc"

		if (sqlca.sqlcode < 0)
			printf("fetch relative -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
		else
			printf("fetch relative -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
		for (i = 0; i < sqlca.sqlerrd[2]; i++)
			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 144 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 144 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH RELATIVE +/- 4 using negative positions
	 * readahead is 8, so caching is in effect
	 */

	printf("\ntest scroll_cur for fetch relative -4 (negative positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 153 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 153 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur", ECPGst_normal, "move absolute - 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
#line 157 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 157 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur", ECPGst_normal, "move forward 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
#line 160 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 160 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("move forward 1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);

	quit_loop = 0;
	while (!quit_loop)
	{
		for (i = 0; i < 8; i++)
			id[i] = 0, t[i].arr[0] = '\0';
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch relative - 4 in scroll_cur", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 169 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 169 "cursor-ra-fetch.pgc"

		if (sqlca.sqlcode < 0)
			printf("fetch relative -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
		else
			printf("fetch relative -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
		for (i = 0; i < sqlca.sqlerrd[2]; i++)
			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	printf("\ntest scroll_cur for fetch relative 4 (negative positions)\n");

	quit_loop = 0;
	while (!quit_loop)
	{
		for (i = 0; i < 8; i++)
			id[i] = 0, t[i].arr[0] = '\0';
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "4", 0, "scroll_cur", ECPGst_normal, "fetch relative 4 in scroll_cur", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 186 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 186 "cursor-ra-fetch.pgc"

		if (sqlca.sqlcode < 0)
			printf("fetch relative 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
		else
			printf("fetch relative 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
		for (i = 0; i < sqlca.sqlerrd[2]; i++)
			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 196 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 196 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH FORWARD +/- 4 using positive positions
	 * readahead is 8, so caching is in effect
	 */

	printf("\ntest scroll_cur for fetch forward 4 (positive positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 205 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 205 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	quit_loop = 0;
	while (!quit_loop)
	{
		for (i = 0; i < 8; i++)
			id[i] = 0, t[i].arr[0] = '\0';
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "4", 0, "scroll_cur", ECPGst_normal, "fetch forward 4 in scroll_cur", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 214 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 214 "cursor-ra-fetch.pgc"

		if (sqlca.sqlcode < 0)
			printf("fetch forward 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
		else
			printf("fetch forward 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
		for (i = 0; i < sqlca.sqlerrd[2]; i++)
			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	printf("\ntest scroll_cur for fetch forward -4 (positive positions)\n");

	quit_loop = 0;
	while (!quit_loop)
	{
		for (i = 0; i < 8; i++)
			id[i] = 0, t[i].arr[0] = '\0';
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch forward - 4 in scroll_cur", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 231 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 231 "cursor-ra-fetch.pgc"

		if (sqlca.sqlcode < 0)
			printf("fetch forward -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
		else
			printf("fetch forward -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
		for (i = 0; i < sqlca.sqlerrd[2]; i++)
			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 241 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 241 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH FORWARD +/- 4 using negative positions
	 * readahead is 8, so caching is in effect
	 */

	printf("\ntest scroll_cur for fetch forward -4 (negative positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 250 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 250 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur", ECPGst_normal, "move absolute - 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
#line 254 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 254 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur", ECPGst_normal, "move forward 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
#line 257 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 257 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("move forward 1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);

	quit_loop = 0;
	while (!quit_loop)
	{
		for (i = 0; i < 8; i++)
			id[i] = 0, t[i].arr[0] = '\0';
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch forward - 4 in scroll_cur", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 266 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 266 "cursor-ra-fetch.pgc"

		if (sqlca.sqlcode < 0)
			printf("fetch forward -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
		else
			printf("fetch forward -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
		for (i = 0; i < sqlca.sqlerrd[2]; i++)
			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	printf("\ntest scroll_cur for fetch forward 4 (negative positions)\n");

	quit_loop = 0;
	while (!quit_loop)
	{
		for (i = 0; i < 8; i++)
			id[i] = 0, t[i].arr[0] = '\0';
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "4", 0, "scroll_cur", ECPGst_normal, "fetch forward 4 in scroll_cur", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 283 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 283 "cursor-ra-fetch.pgc"

		if (sqlca.sqlcode < 0)
			printf("fetch forward 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
		else
			printf("fetch forward 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
		for (i = 0; i < sqlca.sqlerrd[2]; i++)
			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 293 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 293 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH ABSOLUTE N with an interval of 5 using positive positions.
	 * Readahead is 4 so cache misses occur.
	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
	 */

	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple forward, positive positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 303 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 303 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	for (i = 1; i < 35; i += 5)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 309 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 309 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
		else
			printf("\trow %d does not exist\n", i);
	}

	/*
	 * Let's see caching recovers by fetching 2x the readahead size.
	 * The cursor must be at the end now, with the cursor's pos,
	 * backend_pos, atstart and atend correctly set.
	 */

	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 325 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 325 "cursor-ra-fetch.pgc"

	for (i = 0; i < sqlca.sqlerrd[2]; i++)
		printf("\tid: %d t: %s\n", id[i], t[i].arr);

	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple backward, positive positions)\n");

	for (i = 36; i >= 0; i -= 5)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 333 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 333 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
		else
			printf("\trow %d does not exist\n", i);
	}

	/*
	 * Let's see caching recovers by fetching 2x the readahead size.
	 * The cursor must be at the start+1 (pos == 1) now,
	 * with the cursor's pos, backend_pos, atstart and atend
	 * correctly set.
	 */

	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 350 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 350 "cursor-ra-fetch.pgc"

	for (i = 0; i < sqlca.sqlerrd[2]; i++)
		printf("\tid: %d t: %s\n", id[i], t[i].arr);

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 354 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 354 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH ABSOLUTE N with an interval of 5 using negative positions.
	 * Readahead is 4 so cache misses occur.
	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
	 */

	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple backward, negative positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 364 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 364 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	for (i = -1; i > -35; i -= 5)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 370 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 370 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
		else
			printf("\trow %d does not exist\n", i);
	}

	/*
	 * Let's see caching recovers by fetching 2x the readahead size.
	 * The cursor must be at the start (pos == -27) now,
	 * with the cursor's pos, backend_pos, atstart and atend
	 * correctly set.
	 */

	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 387 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 387 "cursor-ra-fetch.pgc"

	for (i = 0; i < sqlca.sqlerrd[2]; i++)
		printf("\tid: %d t: %s\n", id[i], t[i].arr);

	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple forward, negative positions)\n");

	for (i = -36; i <= 0; i += 5)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 395 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 395 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
		else
			printf("\trow %d does not exist\n", i);
	}

	/*
	 * Let's see caching recovers by fetching 2x the readahead size.
	 * The cursor must be at the end-1 (pos == -1) now,
	 * with the cursor's pos, backend_pos, atstart and atend
	 * correctly set.
	 */

	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 412 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 412 "cursor-ra-fetch.pgc"

	for (i = 0; i < sqlca.sqlerrd[2]; i++)
		printf("\tid: %d t: %s\n", id[i], t[i].arr);

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 416 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 416 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH RELATIVE +/- 5 using positive positions.
	 * Readahead is 4 so cache misses occur.
	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
	 */

	printf("\ntest scroll_cur4 for fetch relative 5 (positive positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 426 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 426 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	quit_loop = 0;
	while (!quit_loop)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "5", 0, "scroll_cur4", ECPGst_normal, "fetch relative 5 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 433 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 433 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
		else
			printf("\tfetch returned empty\n");
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	/*
	 * Let's see caching recovers by fetching 2x the readahead size.
	 * The cursor must be at the end now,
	 * with the cursor's pos, backend_pos, atstart and atend
	 * correctly set.
	 */

	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 451 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 451 "cursor-ra-fetch.pgc"

	for (i = 0; i < sqlca.sqlerrd[2]; i++)
		printf("\tid: %d t: %s\n", id[i], t[i].arr);

	/* Exaggerate the number of tuples, move to the end. */
	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "100", 1, "scroll_cur4", ECPGst_normal, "move forward 100 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT);
#line 456 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 456 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("move forward 100 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);

	printf("\ntest scroll_cur4 for fetch relative -5 (positive positions)\n");

	quit_loop = 0;
	while (!quit_loop)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 5", 0, "scroll_cur4", ECPGst_normal, "fetch relative - 5 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 465 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 465 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
		else
			printf("\tfetch returned empty\n");
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	/*
	 * Let's see caching recovers by fetching 2x the readahead size.
	 * The cursor must be at the start now,
	 * with the cursor's pos, backend_pos, atstart and atend
	 * correctly set.
	 */

	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 483 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 483 "cursor-ra-fetch.pgc"

	for (i = 0; i < sqlca.sqlerrd[2]; i++)
		printf("\tid: %d t: %s\n", id[i], t[i].arr);

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 487 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 487 "cursor-ra-fetch.pgc"


	/*
	 * Test FETCH RELATIVE +/- 5 using negative positions.
	 * Readahead is 4 so cache misses occur.
	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
	 */

	printf("\ntest scroll_cur4 for move relative -5 (negative positions)\n");

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
#line 497 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 497 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur4", ECPGst_normal, "move absolute - 1 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT);
#line 501 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 501 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("move absolute -1 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur4", ECPGst_normal, "move forward 1 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT);
#line 504 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 504 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("move forward 1 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);

	quit_loop = 0;
	while (!quit_loop)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 5", 0, "scroll_cur4", ECPGst_normal, "fetch relative - 5 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 511 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 511 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
		else
			printf("\tfetch returned empty\n");
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	/*
	 * Let's see caching recovers by fetching 2x the readahead size.
	 * The cursor must be at the start now,
	 * with the cursor's pos, backend_pos, atstart and atend
	 * correctly set.
	 */

	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 529 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 529 "cursor-ra-fetch.pgc"

	for (i = 0; i < sqlca.sqlerrd[2]; i++)
		printf("\tid: %d t: %s\n", id[i], t[i].arr);

	/* Exaggerate the number of tuples, move to the start. */
	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "100", 1, "scroll_cur4", ECPGst_normal, "move backward 100 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT);
#line 534 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 534 "cursor-ra-fetch.pgc"

	if (sqlca.sqlcode < 0)
		printf("move backward 100 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);

	printf("\ntest scroll_cur for move relative 5 (negative positions)\n");

	quit_loop = 0;
	while (!quit_loop)
	{
		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "5", 0, "scroll_cur4", ECPGst_normal, "fetch relative 5 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 543 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 543 "cursor-ra-fetch.pgc"


		if (sqlca.sqlerrd[2] == 1)
			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
		else
			printf("\tfetch returned empty\n");
		quit_loop = (sqlca.sqlerrd[2] == 0);
	}

	/*
	 * Let's see caching recovers by fetching 2x the readahead size.
	 * The cursor must be at the end now,
	 * with the cursor's pos, backend_pos, atstart and atend
	 * correctly set.
	 */

	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");

	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, 
	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 561 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 561 "cursor-ra-fetch.pgc"

	for (i = 0; i < sqlca.sqlerrd[2]; i++)
		printf("\tid: %d t: %s\n", id[i], t[i].arr);

	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
#line 565 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 565 "cursor-ra-fetch.pgc"


	/* Drop the test table */

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
#line 569 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 569 "cursor-ra-fetch.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
#line 570 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 570 "cursor-ra-fetch.pgc"


	{ ECPGdisconnect(__LINE__, "ALL");
#line 572 "cursor-ra-fetch.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 572 "cursor-ra-fetch.pgc"


	return 0;
}
Exemplo n.º 6
0
/*
 * default connection: con2
 * Non-default connection: con1
 *
 */
void execute_test(void)
{
    /* exec sql begin declare section */
     
       
    
#line 63 "declare.pgc"
 int i ;
 
#line 64 "declare.pgc"
 char * selectString = "SELECT f1,f2,f3 FROM source" ;
/* exec sql end declare section */
#line 65 "declare.pgc"


    /*
     * testcase1. using DECLARE STATEMENT without using AT clause,
     * using PREPARE and CURSOR statement without using AT clause
     */
    reset();

    { ECPGdeclare(__LINE__, NULL, "stmt_1");
#line 73 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 73 "declare.pgc"

    { ECPGprepare(__LINE__, NULL, 0, "stmt_1", selectString);
#line 74 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 74 "declare.pgc"

    /* declare cur_1 cursor for $1 */
#line 75 "declare.pgc"

    { ECPGopen("cur_1", "stmt_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_1 cursor for $1", 
	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 76 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 76 "declare.pgc"


    /* exec sql whenever not found  break ; */
#line 78 "declare.pgc"

    i = 0;
    while (1)
    {
        { ECPGfetch("cur_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_1", ECPGt_EOIT, 
	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 82 "declare.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 82 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 82 "declare.pgc"

        i++;
    }
    { ECPGclose("cur_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_1", ECPGt_EOIT, ECPGt_EORT);
#line 85 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 85 "declare.pgc"

    { ECPGdeallocate(__LINE__, 0, NULL, "stmt_1");
#line 86 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 86 "declare.pgc"

    /* exec sql whenever not found  continue ; */
#line 87 "declare.pgc"


    printResult("testcase1", 2);


    /*
     * testcase2. using DECLARE STATEMENT at con1,
     * using PREPARE and CURSOR statement without using AT clause
     */
    reset();

    { ECPGdeclare(__LINE__, "con1", "stmt_2");
#line 98 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 98 "declare.pgc"

    { ECPGprepare(__LINE__, NULL, 0, "stmt_2", selectString);
#line 99 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 99 "declare.pgc"

    /* declare cur_2 cursor for $1 */
#line 100 "declare.pgc"

    { ECPGopen("cur_2", "stmt_2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_2 cursor for $1", 
	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 101 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 101 "declare.pgc"


    /* exec sql whenever not found  break ; */
#line 103 "declare.pgc"

    i = 0;
    while (1)
    {
        { ECPGfetch("cur_2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_2", ECPGt_EOIT, 
	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 107 "declare.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 107 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 107 "declare.pgc"

        i++;
    }
    { ECPGclose("cur_2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_2", ECPGt_EOIT, ECPGt_EORT);
#line 110 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 110 "declare.pgc"

    { ECPGdeallocate(__LINE__, 0, NULL, "stmt_2");
#line 111 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 111 "declare.pgc"

    /* exec sql whenever not found  continue ; */
#line 112 "declare.pgc"


    printResult("testcase2", 2);

    /*
     * testcase3. using DECLARE STATEMENT at con1,
     * using PREPARE and CURSOR statement at con2
     */
    reset();

    { ECPGdeclare(__LINE__, "con1", "stmt_3");
#line 122 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 122 "declare.pgc"

    { ECPGprepare(__LINE__, "con2", 0, "stmt_3", selectString);
#line 123 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 123 "declare.pgc"

    /* declare cur_3 cursor for $1 */
#line 124 "declare.pgc"

    { ECPGopen("cur_3", "stmt_3", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_3 cursor for $1", 
	ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_3", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 125 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 125 "declare.pgc"


    /* exec sql whenever not found  break ; */
#line 127 "declare.pgc"

    i = 0;
    while (1)
    {
        { ECPGfetch("cur_3", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch cur_3", ECPGt_EOIT, 
	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 131 "declare.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 131 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 131 "declare.pgc"

        i++;
    }
    { ECPGclose("cur_3", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_3", ECPGt_EOIT, ECPGt_EORT);
#line 134 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 134 "declare.pgc"

    { ECPGdeallocate(__LINE__, 0, "con2", "stmt_3");
#line 135 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 135 "declare.pgc"

    /* exec sql whenever not found  continue ; */
#line 136 "declare.pgc"


    printResult("testcase3", 2);


    /*
     * testcase4. using DECLARE STATEMENT without using AT clause,
     * using PREPARE and CURSOR statement at con2
     */
    reset();

    { ECPGdeclare(__LINE__, NULL, "stmt_4");
#line 147 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 147 "declare.pgc"

    { ECPGprepare(__LINE__, "con2", 0, "stmt_4", selectString);
#line 148 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 148 "declare.pgc"

    /* declare cur_4 cursor for $1 */
#line 149 "declare.pgc"

    { ECPGopen("cur_4", "stmt_4", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_4 cursor for $1", 
	ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_4", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 150 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 150 "declare.pgc"


    /* exec sql whenever not found  break ; */
#line 152 "declare.pgc"

    i = 0;
    while (1)
    {
        { ECPGfetch("cur_4", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch cur_4", ECPGt_EOIT, 
	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 156 "declare.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 156 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 156 "declare.pgc"

        i++;
    }
    { ECPGclose("cur_4", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_4", ECPGt_EOIT, ECPGt_EORT);
#line 159 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 159 "declare.pgc"

    { ECPGdeallocate(__LINE__, 0, "con2", "stmt_4");
#line 160 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 160 "declare.pgc"

    /* exec sql whenever not found  continue ; */
#line 161 "declare.pgc"


    printResult("testcase4", 2);

    /*
     * testcase5. using DECLARE STATEMENT without using AT clause,
     * using PREPARE and EXECUTE statement without using AT clause
     */
    reset();

    { ECPGdeclare(__LINE__, NULL, "stmt_5");
#line 171 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 171 "declare.pgc"

    { ECPGprepare(__LINE__, NULL, 0, "stmt_5", selectString);
#line 172 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 172 "declare.pgc"

    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_5", ECPGt_EOIT, 
	ECPGt_int,(f1),(long)1,(long)ARRAY_SZIE,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,(f2),(long)1,(long)ARRAY_SZIE,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(f3),(long)20,(long)ARRAY_SZIE,(20)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 173 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 173 "declare.pgc"


    { ECPGdeallocate(__LINE__, 0, NULL, "stmt_5");
#line 175 "declare.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 175 "declare.pgc"


    printResult("testcase5", 2);
}