Ejemplo n.º 1
0
static void
get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
{
	/* exec sql begin declare section */
			  
		  
	
#line 22 "outofscope.pgc"
 MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
 
#line 23 "outofscope.pgc"
 MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
/* exec sql end declare section */
#line 24 "outofscope.pgc"


	/* Test DECLARE ... SELECT ... INTO with pointers */

	ECPGset_var( 0, ( myvar ), __LINE__);\
 ECPGset_var( 1, ( mynullvar ), __LINE__);\
 /* declare mycur cursor for select * from a1 */
#line 28 "outofscope.pgc"


	if (sqlca.sqlcode != 0)
		exit(1);

	*myvar0 = myvar;
	*mynullvar0 = mynullvar;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 4
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);
}