Exemplo n.º 1
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.º 2
0
int main(void)
{
   /* exec sql begin declare section */
      
      
   
#line 10 "define.pgc"
 int i ;
 
#line 11 "define.pgc"
 char s [ 200 ] ;
/* exec sql end declare section */
#line 12 "define.pgc"


   ECPGdebug(1, stderr);

   /* exec sql whenever sqlerror  do sqlprint ( ) ; */
#line 16 "define.pgc"

   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 17 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 17 "define.pgc"


   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( a int , b text )", ECPGt_EOIT, ECPGt_EORT);
#line 19 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 19 "define.pgc"

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'abcdef' )", ECPGt_EOIT, ECPGt_EORT);
#line 20 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 20 "define.pgc"


   
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'defined' )", ECPGt_EOIT, ECPGt_EORT);
#line 23 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 23 "define.pgc"

   

   
           
   
           
   
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'someothervar not defined' )", ECPGt_EOIT, ECPGt_EORT);
#line 31 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 31 "define.pgc"

   

   

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1 , 29 :: text || '-' || 'abcdef'", ECPGt_EOIT, 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(s),(long)200,(long)1,(200)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 36 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 36 "define.pgc"


   printf("i: %d, s: %s\n", i, s);

   
   
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'no string' )", ECPGt_EOIT, ECPGt_EORT);
#line 42 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 42 "define.pgc"

   

     /* no value */
   

   
        
   
        
   
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT);
#line 53 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 53 "define.pgc"

   

   { ECPGdisconnect(__LINE__, "CURRENT");
#line 56 "define.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 56 "define.pgc"

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

#line 16 "test5.pgc"
 char db [ 200 ] ;
 
#line 17 "test5.pgc"
 char id [ 200 ] ;
 
#line 18 "test5.pgc"
 char * user = "******" ;
/* exec sql end declare section */
#line 19 "test5.pgc"


	ECPGdebug(1, stderr);

	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
#line 23 "test5.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
#line 24 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 25 "test5.pgc"
  /* <-- "main" not specified */

	strcpy(db, "connectdb");
	strcpy(id, "main");
	{ ECPGconnect(__LINE__, 0, db , NULL, NULL , id, 0); }
#line 29 "test5.pgc"

	{ ECPGdisconnect(__LINE__, id);}
#line 30 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
#line 32 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 33 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
#line 35 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 36 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
#line 38 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 39 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "" , "connectdb" , NULL , "main", 0); }
#line 41 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 42 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "connectdb" , "connectuser" , "connectdb" , "main", 0); }
#line 44 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 45 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
#line 47 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 48 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
#line 50 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 51 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , user , NULL , "main", 0); }
#line 53 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 54 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb?connect_timeout=14 & client_encoding=latin1" , "connectuser" , NULL , "main", 0); }
#line 56 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 57 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb" , "connectuser" , NULL , "main", 0); }
#line 59 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 60 "test5.pgc"


	{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "connectdb" , NULL , "main", 0); }
#line 62 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 63 "test5.pgc"


	/* connect twice */
	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
#line 66 "test5.pgc"

	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
#line 67 "test5.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 68 "test5.pgc"


	/* not connected */
	{ ECPGdisconnect(__LINE__, "nonexistant");}
#line 71 "test5.pgc"


	return (0);
}
Exemplo n.º 4
0
int
main(void)
{
	/* exec sql begin declare section */
		
		
		
		
	
#line 19 "nan_test.pgc"
 int id ;
 
#line 20 "nan_test.pgc"
 double d ;
 
#line 21 "nan_test.pgc"
 numeric * num ;
 
#line 22 "nan_test.pgc"
 char val [ 16 ] ;
/* exec sql end declare section */
#line 23 "nan_test.pgc"


	ECPGdebug(1, stderr);
	/* exec sql whenever sqlerror  do sqlprint ( ) ; */
#line 26 "nan_test.pgc"


	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 28 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 28 "nan_test.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table nantest1 ( id int4 , d float8 )", ECPGt_EOIT, ECPGt_EORT);
#line 30 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 30 "nan_test.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( 1 , 'nan' :: float8 ) , ( 2 , 'infinity' :: float8 ) , ( 3 , '-infinity' :: float8 )", ECPGt_EOIT, ECPGt_EORT);
#line 31 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 31 "nan_test.pgc"


	/* declare cur cursor for select id , d , d from nantest1 */
#line 33 "nan_test.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
#line 34 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 34 "nan_test.pgc"

	while (1)
	{
		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_double,&(d),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 37 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 37 "nan_test.pgc"

		if (sqlca.sqlcode)
			break;
		if (isnan(d))
			printf("%d  NaN '%s'\n", id, val);
		else if (isinf(d))
			printf("%d %sInf '%s'\n", id, (d < 0 ? "-" : "+"), val);

		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( $1  + 3 , $2  )", 
	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_double,&(d),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 45 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 45 "nan_test.pgc"

		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( $1  + 6 , $2  )", 
	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 46 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 46 "nan_test.pgc"

	}
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
#line 48 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 48 "nan_test.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
#line 50 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 50 "nan_test.pgc"

	while (1)
	{
		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_double,&(d),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 53 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 53 "nan_test.pgc"

		if (sqlca.sqlcode)
			break;
		if (isinf(d))
			printf("%d %sInf '%s'\n", id, (d < 0 ? "-" : "+"), val);
		if (isnan(d))
			printf("%d  NaN '%s'\n", id, val);
	}
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
#line 61 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 61 "nan_test.pgc"


	num = PGTYPESnumeric_new();

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table nantest2 ( id int4 , d numeric )", ECPGt_EOIT, ECPGt_EORT);
#line 65 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 65 "nan_test.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 4 , 'nan' :: numeric )", ECPGt_EOIT, ECPGt_EORT);
#line 66 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 66 "nan_test.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id , d , d from nantest2 where id = 4", ECPGt_EOIT, 
	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 68 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 68 "nan_test.pgc"


	printf("%d %s '%s'\n", id, (num->sign == NUMERIC_NAN ? "NaN" : "not NaN"), val);

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 5 , $1  )", 
	ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 72 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 72 "nan_test.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 6 , $1  )", 
	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 73 "nan_test.pgc"

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


	/* declare cur1 cursor for select id , d , d from nantest2 */
#line 75 "nan_test.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
#line 76 "nan_test.pgc"

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

	while (1)
	{
		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur1", ECPGt_EOIT, 
	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 79 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 79 "nan_test.pgc"

		if (sqlca.sqlcode)
			break;
		printf("%d %s '%s'\n", id, (num->sign == NUMERIC_NAN ? "NaN" : "not NaN"), val);
	}
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
#line 84 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 84 "nan_test.pgc"


	PGTYPESnumeric_free(num);

	{ ECPGtrans(__LINE__, NULL, "rollback");
#line 88 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 88 "nan_test.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 89 "nan_test.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 89 "nan_test.pgc"


	return (0);
}
int
main(void)
{
	/* exec sql begin declare section */
		 
		  
		 
		 
		 
	
#line 52 "dt_test2.pgc"
 date  date1    ;
 
#line 53 "dt_test2.pgc"
 timestamp  ts1    ,  ts2    ;
 
#line 54 "dt_test2.pgc"
 char * text    ;
 
#line 55 "dt_test2.pgc"
 interval * i1    ;
 
#line 56 "dt_test2.pgc"
 date * dc    ;
/* exec sql end declare section */
#line 57 "dt_test2.pgc"


	int i, j;
	char *endptr;

	ECPGdebug(1, stderr);

	ts1 = PGTYPEStimestamp_from_asc("2003-12-04 17:34:29", NULL);
	text = PGTYPEStimestamp_to_asc(ts1);

	printf("timestamp: %s\n", text);
	free(text);

	date1 = PGTYPESdate_from_timestamp(ts1);
	dc = PGTYPESdate_new();
	*dc = date1;
	text = PGTYPESdate_to_asc(*dc);
	printf("Date of timestamp: %s\n", text);
	free(text);
	PGTYPESdate_free(dc);

	for (i = 0; dates[i]; i++)
	{
		bool err = false;
		date1 = PGTYPESdate_from_asc(dates[i], &endptr);
		if (date1 == INT_MIN) {
			err = true;
		}
		text = PGTYPESdate_to_asc(date1);
		printf("Date[%d]: %s (%c - %c)\n",
					i, err ? "-" : text,
					endptr ? 'N' : 'Y',
					err ? 'T' : 'F');
		free(text);
		if (!err)
		{
			for (j = 0; times[j]; j++)
			{
				int length = strlen(dates[i])
						+ 1
						+ strlen(times[j])
						+ 1;
				char* t = malloc(length);
				sprintf(t, "%s %s", dates[i], times[j]);
				ts1 = PGTYPEStimestamp_from_asc(t, NULL);
				text = PGTYPEStimestamp_to_asc(ts1);
				if (i != 19 || j != 3) /* timestamp as integer or double differ for this case */
					printf("TS[%d,%d]: %s\n",
						i, j, errno ? "-" : text);
				free(text);
			}
		}
	}

	ts1 = PGTYPEStimestamp_from_asc("2004-04-04 23:23:23", NULL);

	for (i = 0; intervals[i]; i++)
	{
		interval *ic;
		i1 = PGTYPESinterval_from_asc(intervals[i], &endptr);
		if (*endptr)
			printf("endptr set to %s\n", endptr);
		if (!i1)
		{
			printf("Error parsing interval %d\n", i);
			continue;
		}
		j = PGTYPEStimestamp_add_interval(&ts1, i1, &ts2);
		if (j < 0)
			continue;
		text = PGTYPESinterval_to_asc(i1);
		printf("interval[%d]: %s\n", i, text ? text : "-");
		free(text);

		ic = PGTYPESinterval_new();
		PGTYPESinterval_copy(i1, ic);
		text = PGTYPESinterval_to_asc(i1);
		printf("interval_copy[%d]: %s\n", i, text ? text : "-");
		free(text);
		PGTYPESinterval_free(ic);
	}

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

#line 14 "oldexec.pgc"
 int amount [ 8 ] ;
 
#line 15 "oldexec.pgc"
 int increment = 100 ;
 
#line 16 "oldexec.pgc"
 char name [ 8 ] [ 8 ] ;
 
#line 17 "oldexec.pgc"
 char letter [ 8 ] [ 1 ] ;
 
#line 18 "oldexec.pgc"
 char command [ 128 ] ;
/* exec sql end declare section */
#line 19 "oldexec.pgc"

	int i,j;

	ECPGdebug(1, stderr);

	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "main", 0); 
#line 24 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 24 "oldexec.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )", ECPGt_EOIT, ECPGt_EORT);
#line 25 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 25 "oldexec.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 26 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 26 "oldexec.pgc"


	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')");
	{ ECPGdo(__LINE__, 0, 1, NULL, 1, 2, command, ECPGt_EOIT, ECPGt_EORT);
#line 29 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 29 "oldexec.pgc"


	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
	{ ECPGdo(__LINE__, 0, 1, NULL, 1, 2, command, ECPGt_EOIT, ECPGt_EORT);
#line 32 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 32 "oldexec.pgc"


	sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
	{ ECPGdo(__LINE__, 0, 1, NULL, 1, 2, command, ECPGt_EOIT, ECPGt_EORT);
#line 35 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 35 "oldexec.pgc"


	printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]);

	sprintf(command, "insert into test (name, amount, letter) select name, amount+$1, letter from test");
	{ ECPGprepare(__LINE__, NULL, 1, "i", command);
#line 40 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 40 "oldexec.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 1, 1, "i", 
	ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 41 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 41 "oldexec.pgc"


	printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 45 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 45 "oldexec.pgc"


	sprintf (command, "select * from test");

	{ ECPGprepare(__LINE__, NULL, 1, "f", command);
#line 49 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 49 "oldexec.pgc"

	/* declare CUR cursor for $1 */
#line 50 "oldexec.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR cursor for $1", 
	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 52 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 52 "oldexec.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 53 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 53 "oldexec.pgc"


	for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
	{
		/* exec sql begin declare section */
		    
		   
		
#line 58 "oldexec.pgc"
 char n [ 8 ] , l = letter [ i ] [ 0 ] ;
 
#line 59 "oldexec.pgc"
 int a = amount [ i ] ;
/* exec sql end declare section */
#line 60 "oldexec.pgc"


		strncpy(n, name[i], 8);
		printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
	}

	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
#line 66 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 66 "oldexec.pgc"


	sprintf (command, "select * from test where ? = amount");

	{ ECPGprepare(__LINE__, NULL, 1, "f", command);
#line 70 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 70 "oldexec.pgc"

	/* declare CUR3 cursor for $1 */
#line 71 "oldexec.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR3 cursor for $1", 
	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 73 "oldexec.pgc"

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

	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT, 
	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 74 "oldexec.pgc"

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


	for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
	{
		/* exec sql begin declare section */
		    
		   
		
#line 79 "oldexec.pgc"
 char n [ 8 ] , l = letter [ i ] [ 0 ] ;
 
#line 80 "oldexec.pgc"
 int a = amount [ i ] ;
/* exec sql end declare section */
#line 81 "oldexec.pgc"


		strncpy(n, name[i], 8);
		printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
	}

	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR3", ECPGt_EOIT, ECPGt_EORT);
#line 87 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 87 "oldexec.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
#line 88 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 88 "oldexec.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 89 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 89 "oldexec.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 90 "oldexec.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 90 "oldexec.pgc"


	return (0);
}
Exemplo n.º 7
0
int main(void)
{
	struct sa x = { 14 },*y = &x;
	/* exec sql begin declare section */
		 
		 
		 
		 
		 
		 
		 

		 
		 
		 
		  /* = 1L */ 
	
#line 60 "init.pgc"
 int a = ( int ) 2 ;
 
#line 61 "init.pgc"
 int b = 2 + 2 ;
 
#line 62 "init.pgc"
 int b2 = ( 14 * 7 ) ;
 
#line 63 "init.pgc"
 int d = x . member ;
 
#line 64 "init.pgc"
 int g = fb ( 2 ) ;
 
#line 65 "init.pgc"
 int i = 3 ^ 1 ;
 
#line 66 "init.pgc"
 int j = 1 ? 1 : 2 ;
 
#line 68 "init.pgc"
 int e = y -> member ;
 
#line 69 "init.pgc"
 int c = 10 >> 2 ;
 
#line 70 "init.pgc"
 bool h = 2 || 1 ;
 
#line 71 "init.pgc"
 long iay ;
/* exec sql end declare section */
#line 72 "init.pgc"


	int f=fa();

#ifdef _cplusplus
	/* exec sql begin declare section */
	  /* compile error */
	
#line 78 "init.pgc"
 int k = N : : i ;
/* exec sql end declare section */
#line 79 "init.pgc"

#endif

	ECPGdebug(1, stderr);

	printf("%d %d %d %d %d %d %d %d %d %d %d\n", a, b, b2, c, d, e, f, g, h, i, j);
	iay = 0;
	printf("%ld\n", iay);
	/* exec sql whenever sqlerror  do fa ( ) ; */
#line 87 "init.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select now ( )", ECPGt_EOIT, ECPGt_EORT);
#line 88 "init.pgc"

if (sqlca.sqlcode < 0) fa ( );}
#line 88 "init.pgc"

	/* exec sql whenever sqlerror  do fb ( 20 ) ; */
#line 89 "init.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select now ( )", ECPGt_EOIT, ECPGt_EORT);
#line 90 "init.pgc"

if (sqlca.sqlcode < 0) fb ( 20 );}
#line 90 "init.pgc"

	/* exec sql whenever sqlerror  do fc ( \"50\" ) ; */
#line 91 "init.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select now ( )", ECPGt_EOIT, ECPGt_EORT);
#line 92 "init.pgc"

if (sqlca.sqlcode < 0) fc ( "50" );}
#line 92 "init.pgc"

	/* exec sql whenever sqlerror  do fd ( \"50\" , 1 ) ; */
#line 93 "init.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select now ( )", ECPGt_EOIT, ECPGt_EORT);
#line 94 "init.pgc"

if (sqlca.sqlcode < 0) fd ( "50" , 1 );}
#line 94 "init.pgc"

	/* exec sql whenever sqlerror  do fe ( ENUM0 ) ; */
#line 95 "init.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select now ( )", ECPGt_EOIT, ECPGt_EORT);
#line 96 "init.pgc"

if (sqlca.sqlcode < 0) fe ( ENUM0 );}
#line 96 "init.pgc"

	/* exec sql whenever sqlerror  do sqlnotice ( NULL , 0 ) ; */
#line 97 "init.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select now ( )", ECPGt_EOIT, ECPGt_EORT);
#line 98 "init.pgc"

if (sqlca.sqlcode < 0) sqlnotice ( NULL , 0 );}
#line 98 "init.pgc"

	return 0;
}
Exemplo n.º 8
0
int main(void)
{
   /* exec sql begin declare section */
        
     
    
    
    
    
    
/*   char **d8=0; */
    
    
    
    
    
    
    
    
/*   int *i8=0; */
    
   
#line 9 "dynalloc.pgc"
 int * d1 = 0 ;
 
#line 10 "dynalloc.pgc"
 double * d2 = 0 ;
 
#line 11 "dynalloc.pgc"
 char ** d3 = 0 ;
 
#line 12 "dynalloc.pgc"
 char ** d4 = 0 ;
 
#line 13 "dynalloc.pgc"
 char ** d5 = 0 ;
 
#line 14 "dynalloc.pgc"
 char ** d6 = 0 ;
 
#line 15 "dynalloc.pgc"
 char ** d7 = 0 ;
 
#line 17 "dynalloc.pgc"
 char ** d9 = 0 ;
 
#line 18 "dynalloc.pgc"
 int * i1 = 0 ;
 
#line 19 "dynalloc.pgc"
 int * i2 = 0 ;
 
#line 20 "dynalloc.pgc"
 int * i3 = 0 ;
 
#line 21 "dynalloc.pgc"
 int * i4 = 0 ;
 
#line 22 "dynalloc.pgc"
 int * i5 = 0 ;
 
#line 23 "dynalloc.pgc"
 int * i6 = 0 ;
 
#line 24 "dynalloc.pgc"
 int * i7 = 0 ;
 
#line 26 "dynalloc.pgc"
 int * i9 = 0 ;
/* exec sql end declare section */
#line 27 "dynalloc.pgc"

   int i;

   ECPGdebug(1, stderr);

   /* exec sql whenever sqlerror  do sqlprint ( ) ; */
#line 32 "dynalloc.pgc"

   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 33 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 33 "dynalloc.pgc"


   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to mdy", ECPGt_EOIT, ECPGt_EORT);
#line 35 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 35 "dynalloc.pgc"


   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( a serial , b numeric ( 12 , 3 ) , c varchar , d varchar ( 3 ) , e char ( 4 ) , f timestamptz , g boolean , h box , i inet )", ECPGt_EOIT, ECPGt_EORT);
#line 37 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 37 "dynalloc.pgc"

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( b , c , d , e , f , g , h , i ) values ( 23.456 , 'varchar' , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , true , '(1,2,3,4)' , '2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128' )", ECPGt_EOIT, ECPGt_EORT);
#line 38 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 38 "dynalloc.pgc"

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( b , c , d , e , f , g , h , i ) values ( 2.446456 , null , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , false , null , null )", ECPGt_EOIT, ECPGt_EORT);
#line 39 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 39 "dynalloc.pgc"


   ECPGallocate_desc(__LINE__, "mydesc");
#line 41 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );
#line 41 "dynalloc.pgc"

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , b , c , d , e , f , g , h , i from test order by a", ECPGt_EOIT, 
	ECPGt_descriptor, "mydesc", 1L, 1L, 1L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 42 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 42 "dynalloc.pgc"

   { ECPGget_desc(__LINE__, "mydesc", 1,ECPGd_indicator,
	ECPGt_int,&(i1),(long)1,(long)0,sizeof(int), ECPGd_data,
	ECPGt_int,&(d1),(long)1,(long)0,sizeof(int), ECPGd_EODT);

#line 43 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 43 "dynalloc.pgc"

   { ECPGget_desc(__LINE__, "mydesc", 2,ECPGd_indicator,
	ECPGt_int,&(i2),(long)1,(long)0,sizeof(int), ECPGd_data,
	ECPGt_double,&(d2),(long)1,(long)0,sizeof(double), ECPGd_EODT);

#line 44 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 44 "dynalloc.pgc"

   { ECPGget_desc(__LINE__, "mydesc", 3,ECPGd_indicator,
	ECPGt_int,&(i3),(long)1,(long)0,sizeof(int), ECPGd_data,
	ECPGt_char,&(d3),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);

#line 45 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 45 "dynalloc.pgc"

   { ECPGget_desc(__LINE__, "mydesc", 4,ECPGd_indicator,
	ECPGt_int,&(i4),(long)1,(long)0,sizeof(int), ECPGd_data,
	ECPGt_char,&(d4),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);

#line 46 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 46 "dynalloc.pgc"

   { ECPGget_desc(__LINE__, "mydesc", 5,ECPGd_indicator,
	ECPGt_int,&(i5),(long)1,(long)0,sizeof(int), ECPGd_data,
	ECPGt_char,&(d5),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);

#line 47 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 47 "dynalloc.pgc"

   { ECPGget_desc(__LINE__, "mydesc", 6,ECPGd_indicator,
	ECPGt_int,&(i6),(long)1,(long)0,sizeof(int), ECPGd_data,
	ECPGt_char,&(d6),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);

#line 48 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 48 "dynalloc.pgc"

   { ECPGget_desc(__LINE__, "mydesc", 7,ECPGd_indicator,
	ECPGt_int,&(i7),(long)1,(long)0,sizeof(int), ECPGd_data,
	ECPGt_char,&(d7),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);

#line 49 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 49 "dynalloc.pgc"

   /* skip box for now */
   /* exec sql get descriptor mydesc value 8 :d8=DATA, :i8=INDICATOR; */
   { ECPGget_desc(__LINE__, "mydesc", 9,ECPGd_indicator,
	ECPGt_int,&(i9),(long)1,(long)0,sizeof(int), ECPGd_data,
	ECPGt_char,&(d9),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);

#line 52 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 52 "dynalloc.pgc"


   printf("Result:\n");
   for (i=0;i<sqlca.sqlerrd[2];++i)
   {
      if (i1[i]) printf("NULL, ");
      else printf("%d, ",d1[i]);

      if (i2[i]) printf("NULL, ");
      else printf("%f, ",d2[i]);

      if (i3[i]) printf("NULL, ");
      else printf("'%s', ",d3[i]);

      if (i4[i]) printf("NULL, ");
      else printf("'%s', ",d4[i]);

      if (i5[i]) printf("NULL, ");
      else printf("'%s', ",d5[i]);

      if (i6[i]) printf("NULL, ");
      else printf("'%s', ",d6[i]);

      if (i7[i]) printf("NULL, ");
      else printf("'%s', ",d7[i]);

      if (i9[i]) printf("NULL, ");
      else printf("'%s', ",d9[i]);

      printf("\n");
   }
   ECPGfree_auto_mem();
   printf("\n");

   ECPGdeallocate_desc(__LINE__, "mydesc");
#line 86 "dynalloc.pgc"

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

   { ECPGdisconnect(__LINE__, "CURRENT");
#line 87 "dynalloc.pgc"

if (sqlca.sqlcode < 0) sqlprint ( );}
#line 87 "dynalloc.pgc"

   return 0;
}
Exemplo n.º 9
0
int
main(void)
{
	short mdy[3] = { 11, 23, 1959 };
	char dbuf[11];
	date d;
	int r;

	ECPGdebug(1, stderr);

	r = rmdyjul(mdy, &d);
	printf("create: r: %d\n", r);
	if (r == 0)
	{
		rdatestr(d, dbuf);
		printf("date: %s\n", dbuf);
	}

	/* input mask is mmddyyyy */
	date_test_strdate("12031994");
	date_test_strdate("9.6.1994");

	date_test_fmt(d, "mmddyy");
	date_test_fmt(d, "ddmmyy");
	date_test_fmt(d, "yymmdd");
	date_test_fmt(d, "yy/mm/dd");
	date_test_fmt(d, "yy mm dd");
	date_test_fmt(d, "yy.mm.dd");
	date_test_fmt(d, ".mm.yyyy.dd.");
	date_test_fmt(d, "mmm. dd, yyyy");
	date_test_fmt(d, "mmm dd yyyy");
	date_test_fmt(d, "yyyy dd mm");
	date_test_fmt(d, "ddd, mmm. dd, yyyy");
	date_test_fmt(d, "(ddd) mmm. dd, yyyy");

	date_test_defmt("ddmmyy", "21-2-54");
	date_test_defmt("ddmmyy", "2-12-54");
	date_test_defmt("ddmmyy", "20111954");
	date_test_defmt("ddmmyy", "130464");
	date_test_defmt("mmm.dd.yyyy", "MAR-12-1967");
	date_test_defmt("yy/mm/dd", "1954, February 3rd");
	date_test_defmt("mmm.dd.yyyy", "041269");
	date_test_defmt("yy/mm/dd", "In the year 2525, in the month of July, mankind will be alive on the 28th day");
	date_test_defmt("dd-mm-yy", "I said on the 28th of July in the year 2525");
	date_test_defmt("mmm.dd.yyyy", "9/14/58");
	date_test_defmt("yy/mm/dd", "47/03/29");
	date_test_defmt("mmm.dd.yyyy", "oct 28 1975");
	date_test_defmt("mmddyy", "Nov 14th, 1985");
	/* ok: still contains dd mm yy */
	date_test_defmt("bladdfoommbaryybong", "20/11/1954");
	/* 1994 is not a leap year, it accepts the date as 01-03-1994 */
	date_test_defmt("ddmmyy", "29-02-1994");

	/* ECPG_INFORMIX_ENOTDMY, need "dd", "mm" and "yy" */
	date_test_defmt("dmy", "20/11/1954");

	/* ECPG_INFORMIX_ENOSHORTDATE */
	date_test_defmt("ddmmyy", "21254");
	date_test_defmt("ddmmyy", "    21254    ");

	/* ECPG_INFORMIX_BAD_DAY */
	date_test_defmt("ddmmyy", "320494");

	/* ECPG_INFORMIX_BAD_MONTH */
	date_test_defmt("mm-yyyy-dd", "13-1993-21");

	/* ECPG_INFORMIX_BAD_YEAR */
	/* ??? */

	return (0);
}
Exemplo n.º 10
0
int main(void)
{
    setlocale(LC_ALL, "C");

    ECPGdebug(1, stderr);

    { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con1", 0); 
#line 29 "declare.pgc"

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

    { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "con2", 0); 
#line 30 "declare.pgc"

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


    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
#line 32 "declare.pgc"

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

    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
#line 33 "declare.pgc"

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


    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT);
#line 35 "declare.pgc"

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

    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT);
#line 36 "declare.pgc"

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


    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT);
#line 38 "declare.pgc"

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

    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT);
#line 39 "declare.pgc"

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


    commitTable();

    execute_test();

    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT);
#line 45 "declare.pgc"

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

    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT);
#line 46 "declare.pgc"

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


    commitTable();

    { ECPGdisconnect(__LINE__, "ALL");
#line 50 "declare.pgc"

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


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

#line 14 "array.pgc"
 int  i   = 1 ;
 
#line 15 "array.pgc"
 int * did   = & i ;
 
#line 16 "array.pgc"
 int  a [ 10 ]   = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ;
 
#line 17 "array.pgc"
 char  text [ 25 ]   = "klmnopqrst" ;
 
#line 18 "array.pgc"
 char * t   = ( char * ) malloc ( 11 ) ;
 
#line 19 "array.pgc"
 double  f    ;
/* exec sql end declare section */
#line 20 "array.pgc"


	strcpy(t, "0123456789");
	setlocale(LC_ALL, "C");

	ECPGdebug(1, stderr);

        { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 27 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 27 "array.pgc"


	{ ECPGsetcommit(__LINE__, "on", NULL);
#line 29 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 29 "array.pgc"


 	{ ECPGtrans(__LINE__, NULL, "begin transaction ");
#line 31 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 31 "array.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create  table test ( f float    , i int   , a int [ 10 ]   , text char  ( 10 )    )    ", ECPGt_EOIT, ECPGt_EORT);
#line 33 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 33 "array.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f  , i  , a  , text  ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 35 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 35 "array.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f  , i  , a  , text  ) values ( 140787.0 , 2 ,  $1  ,  $2  ) ", 
	ECPGt_int,(a),(long)1,(long)10,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 37 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 37 "array.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f  , i  , a  , text  ) values ( 14.07 ,  $1  ,  $2  ,  $3  ) ", 
	ECPGt_int,&(did),(long)1,(long)0,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,(a),(long)1,(long)10,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 39 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 39 "array.pgc"


	{ ECPGtrans(__LINE__, NULL, "commit");
#line 41 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 41 "array.pgc"


	{ ECPGtrans(__LINE__, NULL, "begin transaction ");
#line 43 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 43 "array.pgc"
 

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select  f , text  from test where i = 1  ", ECPGt_EOIT, 
	ECPGt_double,&(f),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 48 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 48 "array.pgc"


	printf("Found f=%f text=%10.10s\n", f, text);

	f=140787;
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select  a , text  from test where f =  $1   ", 
	ECPGt_double,&(f),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,(a),(long)1,(long)10,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 56 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 56 "array.pgc"


	for (i = 0; i < 10; i++)
		printf("Found a[%d] = %d\n", i, a[i]);

	printf("Found text=%10.10s\n", t);

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select  a  from test where f =  $1   ", 
	ECPGt_double,&(f),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 66 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 66 "array.pgc"


	printf("Found text=%s\n", text);

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
#line 70 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 70 "array.pgc"


	{ ECPGtrans(__LINE__, NULL, "commit");
#line 72 "array.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 72 "array.pgc"


	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 74 "array.pgc"

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


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

#line 16 "test3.pgc"
 char  id [ 200 ]    ;
 
#line 17 "test3.pgc"
 char  res [ 200 ]    ;
/* exec sql end declare section */
#line 18 "test3.pgc"


	ECPGdebug(1, stderr);

	strcpy(id, "first");
	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , id, 0); }
#line 23 "test3.pgc"

	{ ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); }
#line 24 "test3.pgc"


	/* this selects from "second" which was opened last */
	{ ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT, 
	ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 27 "test3.pgc"


	/* will close "second" */
	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 30 "test3.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT, 
	ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 31 "test3.pgc"


	{ ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); }
#line 33 "test3.pgc"

	/* will close "second" */
	{ ECPGdisconnect(__LINE__, "DEFAULT");}
#line 35 "test3.pgc"


	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "second", 0); }
#line 37 "test3.pgc"

	{ ECPGdisconnect(__LINE__, "ALL");}
#line 38 "test3.pgc"


	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 40 "test3.pgc"

	{ ECPGdisconnect(__LINE__, "DEFAULT");}
#line 41 "test3.pgc"

	{ ECPGdisconnect(__LINE__, "ALL");}
#line 42 "test3.pgc"


	/*
	 * exec sql disconnect;
	 * exec sql disconnect name;
	 *
	 *     are used in other tests
	 */

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

#line 12 "describe.pgc"
 char * stmt1 = "SELECT id, t FROM t1" ;
 
#line 13 "describe.pgc"
 char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
 
#line 14 "describe.pgc"
 int i , count1 , count2 , count3 , count4 ;
 
#line 15 "describe.pgc"
 char field_name1 [ 30 ] = "not set" ;
 
#line 16 "describe.pgc"
 char field_name2 [ 30 ] = "not set" ;
 
#line 17 "describe.pgc"
 char field_name3 [ 30 ] = "not set" ;
 
#line 18 "describe.pgc"
 char field_name4 [ 30 ] = "not set" ;
/* exec sql end declare section */
#line 19 "describe.pgc"


	char msg[128];

	ECPGdebug(1, stderr);

	strcpy(msg, "connect");
	{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); 
#line 26 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 26 "describe.pgc"


	strcpy(msg, "set");
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
#line 29 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 29 "describe.pgc"


	strcpy(msg, "create");
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
#line 32 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 32 "describe.pgc"


	strcpy(msg, "insert");
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
#line 35 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 35 "describe.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
#line 36 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 36 "describe.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
#line 37 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 37 "describe.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
#line 38 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 38 "describe.pgc"


	strcpy(msg, "commit");
	{ ECPGtrans(__LINE__, NULL, "commit");
#line 41 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 41 "describe.pgc"


	/*
	 * Test DESCRIBE with a query producing tuples.
	 * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
	 */

	strcpy(msg, "allocate");
	ECPGallocate_desc(__LINE__, "desc1");
#line 49 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 49 "describe.pgc"

	ECPGallocate_desc(__LINE__, "desc2");
#line 50 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 50 "describe.pgc"

	ECPGallocate_desc(__LINE__, "desc3");
#line 51 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 51 "describe.pgc"

	ECPGallocate_desc(__LINE__, "desc4");
#line 52 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 52 "describe.pgc"


	strcpy(msg, "prepare");
	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
#line 55 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 55 "describe.pgc"


	strcpy(msg, "describe");
	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 58 "describe.pgc"

	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 59 "describe.pgc"

	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 60 "describe.pgc"

	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 61 "describe.pgc"


	strcpy(msg, "get descriptor");
	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));

#line 64 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 64 "describe.pgc"

	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));

#line 65 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 65 "describe.pgc"

	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));

#line 66 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 66 "describe.pgc"

	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));

#line 67 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 67 "describe.pgc"


	if (!(count1 == count2 && count1 == count3 && count1 == count4))
		exit(1);

	for (i = 1; i <= count1; i++)
	{
		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 74 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 74 "describe.pgc"

		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 75 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 75 "describe.pgc"

		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 76 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 76 "describe.pgc"

		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 77 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 77 "describe.pgc"

		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
			field_name1, field_name2, field_name3, field_name4);
	}

	strcpy(msg, "deallocate");
	ECPGdeallocate_desc(__LINE__, "desc1");
#line 83 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 83 "describe.pgc"

	ECPGdeallocate_desc(__LINE__, "desc2");
#line 84 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 84 "describe.pgc"

	ECPGdeallocate_desc(__LINE__, "desc3");
#line 85 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 85 "describe.pgc"

	ECPGdeallocate_desc(__LINE__, "desc4");
#line 86 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 86 "describe.pgc"


	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
#line 88 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 88 "describe.pgc"


	/* Test DESCRIBE with a query not producing tuples */

	strcpy(msg, "allocate");
	ECPGallocate_desc(__LINE__, "desc1");
#line 93 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 93 "describe.pgc"

	ECPGallocate_desc(__LINE__, "desc2");
#line 94 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 94 "describe.pgc"

	ECPGallocate_desc(__LINE__, "desc3");
#line 95 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 95 "describe.pgc"

	ECPGallocate_desc(__LINE__, "desc4");
#line 96 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 96 "describe.pgc"


	strcpy(msg, "prepare");
	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
#line 99 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 99 "describe.pgc"


	strcpy(msg, "describe");
	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 102 "describe.pgc"

	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 103 "describe.pgc"

	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 104 "describe.pgc"

	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 105 "describe.pgc"


	strcpy(msg, "get descriptor");
	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));

#line 108 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 108 "describe.pgc"

	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));

#line 109 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 109 "describe.pgc"

	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));

#line 110 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 110 "describe.pgc"

	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));

#line 111 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 111 "describe.pgc"


	if (!(count1 == count2 && count1 == count3 && count1 == count4))
		exit(1);

	for (i = 1; i <= count1; i++)
	{
		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 118 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 118 "describe.pgc"

		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 119 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 119 "describe.pgc"

		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 120 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 120 "describe.pgc"

		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 121 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 121 "describe.pgc"

		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
			field_name1, field_name2, field_name3, field_name4);
	}

	strcpy(msg, "deallocate");
	ECPGdeallocate_desc(__LINE__, "desc1");
#line 127 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 127 "describe.pgc"

	ECPGdeallocate_desc(__LINE__, "desc2");
#line 128 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 128 "describe.pgc"

	ECPGdeallocate_desc(__LINE__, "desc3");
#line 129 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 129 "describe.pgc"

	ECPGdeallocate_desc(__LINE__, "desc4");
#line 130 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 130 "describe.pgc"


	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
#line 132 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 132 "describe.pgc"



	/* End test */

	strcpy(msg, "drop");
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
#line 138 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 138 "describe.pgc"


	strcpy(msg, "commit");
	{ ECPGtrans(__LINE__, NULL, "commit");
#line 141 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 141 "describe.pgc"


	strcpy(msg, "disconnect"); 
	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 144 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 144 "describe.pgc"


	return (0);
}
Exemplo n.º 14
0
int main()
{  /* exec sql begin declare section */
    
   
#line 9 "code100.pgc"
 int index ;
/* exec sql end declare section */
#line 10 "code100.pgc"



   ECPGdebug(1,stderr);

   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
#line 15 "code100.pgc"

   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( \"index\" numeric ( 3 ) primary key , \"payload\" int4 not null )", ECPGt_EOIT, ECPGt_EORT);}
#line 20 "code100.pgc"

   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
   { ECPGtrans(__LINE__, NULL, "commit work");}
#line 22 "code100.pgc"

   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);

   for (index=0;index<10;++index)
   {  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( payload , index ) values ( 0 , $1  )", 
	ECPGt_int,&(index),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
#line 28 "code100.pgc"

      if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
   }
   { ECPGtrans(__LINE__, NULL, "commit work");}
#line 31 "code100.pgc"

   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update test set payload = payload + 1 where index = - 1", ECPGt_EOIT, ECPGt_EORT);}
#line 35 "code100.pgc"

   if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from test where index = - 1", ECPGt_EOIT, ECPGt_EORT);}
#line 38 "code100.pgc"

   if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( select * from test where index = - 1 )", ECPGt_EOIT, ECPGt_EORT);}
#line 41 "code100.pgc"

   if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);

   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);}
#line 44 "code100.pgc"

   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
   { ECPGtrans(__LINE__, NULL, "commit work");}
#line 46 "code100.pgc"

   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);

   { ECPGdisconnect(__LINE__, "CURRENT");}
#line 49 "code100.pgc"

   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
   return 0;
}
Exemplo n.º 15
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, "ecpg1_regression" , NULL, NULL , "test1", 0); 
#line 39 "cursor.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 39 "cursor.pgc"

	{ ECPGconnect(__LINE__, 0, "ecpg2_regression" , 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");
#line 57 "cursor.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 57 "cursor.pgc"

	{ ECPGtrans(__LINE__, "test2", "commit");
#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 cursor for select id , t from t1 */
#line 64 "cursor.pgc"


	strcpy(msg, "open");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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;
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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;
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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 cursor for select id , t from t1 */
#line 105 "cursor.pgc"


	strcpy(msg, "open");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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;
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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;
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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 cursor for $1 */
#line 149 "cursor.pgc"

	ECPGset_var( 5, &( curname5 ), __LINE__);\
 /* declare $0 cursor for $1 */
#line 150 "cursor.pgc"


	strcpy(msg, "open");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 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"

	{ ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "declare $0 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");
	{ ECPGdo(__LINE__, 0, 1, "test2", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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;
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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;
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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"

	{ ECPGdo(__LINE__, 0, 1, "test2", 0, 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 cursor for $1 */
#line 203 "cursor.pgc"


	strcpy(msg, "open");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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;
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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;
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
	{ ECPGdo(__LINE__, 0, 1, "test1", 0, 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");
#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);
}
Exemplo n.º 16
0
int
main(void)
{
/* exec sql begin declare section */
	 
	 

#line 17 "test2.pgc"
 char  id [ 200 ]    ;
 
#line 18 "test2.pgc"
 char  res [ 200 ]    ;
/* exec sql end declare section */
#line 19 "test2.pgc"


	ECPGdebug(1, stderr);

	strcpy(id, "first");
	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , id, 0); }
#line 24 "test2.pgc"

	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "second", 0); }
#line 25 "test2.pgc"


	/* this selects from "second" which was opened last */
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select  current_database ()     ", ECPGt_EOIT, 
	ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 28 "test2.pgc"

	{ ECPGdo(__LINE__, 0, 1, "first", 0, ECPGst_normal, "select  current_database ()     ", ECPGt_EOIT, 
	ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 29 "test2.pgc"

	{ ECPGdo(__LINE__, 0, 1, "second", 0, ECPGst_normal, "select  current_database ()     ", ECPGt_EOIT, 
	ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 30 "test2.pgc"


	{ ECPGsetconn(__LINE__, "first");}
#line 32 "test2.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select  current_database ()     ", ECPGt_EOIT, 
	ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 33 "test2.pgc"


	/* this will disconnect from "first" */
	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 36 "test2.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select  current_database ()     ", ECPGt_EOIT, 
	ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 37 "test2.pgc"


	/* error here since "first" is already disconnected */
	{ ECPGdisconnect(__LINE__, id);}
#line 40 "test2.pgc"


	/* disconnect from "second" */
	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 43 "test2.pgc"


	return (0);
}
int main(void)
{
	
#line 15 "rnull.pgc"
 char  c []   = "abc       " ;

#line 15 "rnull.pgc"

	
#line 16 "rnull.pgc"
 short  s   = 17 ;

#line 16 "rnull.pgc"

	
#line 17 "rnull.pgc"
 int  i   = - 74874 ;

#line 17 "rnull.pgc"

	
#line 18 "rnull.pgc"
 bool  b   = 1 ;

#line 18 "rnull.pgc"

	
#line 19 "rnull.pgc"
 float  f   = 3.71 ;

#line 19 "rnull.pgc"

	
#line 20 "rnull.pgc"
 long  l   = 487444 ;

#line 20 "rnull.pgc"

	
#line 21 "rnull.pgc"
 double  dbl   = 404.404 ;

#line 21 "rnull.pgc"

	
#line 22 "rnull.pgc"
 decimal  dec    ;

#line 22 "rnull.pgc"

	
#line 23 "rnull.pgc"
 date  dat    ;

#line 23 "rnull.pgc"

	
#line 24 "rnull.pgc"
 timestamp  tmp    ;

#line 24 "rnull.pgc"


	ECPGdebug(1, stderr);
	/* exec sql whenever sqlerror  do sqlprint (  ) ; */
#line 27 "rnull.pgc"


	{ ECPGconnect(__LINE__, 1, "regress1" , NULL,NULL , NULL, 0); 
#line 29 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 29 "rnull.pgc"


	{ ECPGdo(__LINE__, 1, 0, NULL, "create  table test ( id int   , c char  ( 10 )    , s smallint   , i int   , b bool   , f float    , l bigint   , dbl double precision   , dec decimal    , dat date   , tmp timestamptz   )    ", ECPGt_EOIT, ECPGt_EORT);
#line 33 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 33 "rnull.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 34 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 34 "rnull.pgc"


	{ ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id  , c  , s  , i  , b  , f  , l  , dbl  ) values ( 1 ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ) ", 
	ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 38 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 38 "rnull.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 39 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 39 "rnull.pgc"


	rsetnull(CCHARTYPE, (char *) c);
	rsetnull(CSHORTTYPE, (char *) &s);
	rsetnull(CINTTYPE, (char *) &i);
	rsetnull(CBOOLTYPE, (char *) &b);
	rsetnull(CFLOATTYPE, (char *) &f);
	rsetnull(CLONGTYPE, (char *) &l);
	rsetnull(CDOUBLETYPE, (char *) &dbl);
	rsetnull(CDECIMALTYPE, (char *) &dec);
	rsetnull(CDATETYPE, (char *) &dat);
	rsetnull(CDTIMETYPE, (char *) &tmp);

	{ ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id  , c  , s  , i  , b  , f  , l  , dbl  , dec  , dat  , tmp  ) values ( 2 ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ) ", 
	ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 54 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 54 "rnull.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 55 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 55 "rnull.pgc"


	printf("first select\n");

	{ ECPGdo(__LINE__, 1, 0, NULL, "select  c , s , i , b , f , l , dbl , dec , dat , tmp  from test where id = 1  ", ECPGt_EOIT, 
	ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 61 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 61 "rnull.pgc"


	test_null(CCHARTYPE, (char *) c);
	test_null(CSHORTTYPE, (char *) &s);
	test_null(CINTTYPE, (char *) &i);
	test_null(CBOOLTYPE, (char *) &b);
	test_null(CFLOATTYPE, (char *) &f);
	test_null(CLONGTYPE, (char *) &l);
	test_null(CDOUBLETYPE, (char *) &dbl);
	test_null(CDECIMALTYPE, (char *) &dec);
	test_null(CDATETYPE, (char *) &dat);
	test_null(CDTIMETYPE, (char *) &tmp);

	printf("second select\n");

	{ ECPGdo(__LINE__, 1, 0, NULL, "select  c , s , i , b , f , l , dbl , dec , dat , tmp  from test where id = 2  ", ECPGt_EOIT, 
	ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 78 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 78 "rnull.pgc"


	test_null(CCHARTYPE, (char *) c);
	test_null(CSHORTTYPE, (char *) &s);
	test_null(CINTTYPE, (char *) &i);
	test_null(CBOOLTYPE, (char *) &b);
	test_null(CFLOATTYPE, (char *) &f);
	test_null(CLONGTYPE, (char *) &l);
	test_null(CDOUBLETYPE, (char *) &dbl);
	test_null(CDECIMALTYPE, (char *) &dec);
	test_null(CDATETYPE, (char *) &dat);
	test_null(CDTIMETYPE, (char *) &tmp);

	{ ECPGdo(__LINE__, 1, 0, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
#line 91 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 91 "rnull.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 92 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 92 "rnull.pgc"


	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 94 "rnull.pgc"

if (sqlca.sqlcode < 0) sqlprint (  );}
#line 94 "rnull.pgc"


	return 0;
}
Exemplo n.º 18
0
int
main ()
{
/*
  EXEC SQL BEGIN DECLARE SECTION;
  char *fname = "/tmp/foo";
  EXEC SQL END DECLARE SECTION;
*/

  ECPGdebug (1, stderr);

  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
#line 19 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 19 "copystdout.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, "create  table foo ( a int   , b varchar    )    ", ECPGt_EOIT, ECPGt_EORT);
#line 20 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 20 "copystdout.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values ( 5 , 'abc' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 21 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 21 "copystdout.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values ( 6 , 'def' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 22 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 22 "copystdout.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values ( 7 , 'ghi' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 23 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 23 "copystdout.pgc"


  /* produces expected file "/tmp/foo" */
  /* EXEC SQL COPY foo TO:fname WITH DELIMITER ','; */
  /* printf ("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode); */

  { ECPGdo(__LINE__, 0, 1, NULL, "copy  foo  to stdout  with  delimiter  ','", ECPGt_EOIT, ECPGt_EORT);
#line 29 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 29 "copystdout.pgc"

  printf ("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);

  { ECPGdisconnect(__LINE__, "CURRENT");
#line 32 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 32 "copystdout.pgc"


  return 0;
}
Exemplo n.º 19
0
int main(int argc, char* argv[]) {
    /* exec sql begin declare section */



#line 9 "quote.pgc"
    char  var [ 25 ]    ;

#line 10 "quote.pgc"
    int  i    ;
    /* exec sql end declare section */
#line 11 "quote.pgc"


    ECPGdebug(1, stderr);
    {
        ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
    }
#line 14 "quote.pgc"


    {
        ECPGsetcommit(__LINE__, "on", NULL);
    }
#line 16 "quote.pgc"

    /* exec sql whenever sql_warning  sqlprint ; */
#line 17 "quote.pgc"

    /* exec sql whenever sqlerror  sqlprint ; */
#line 18 "quote.pgc"


    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create  table \"My_Table\" ( Item1 int   , Item2 text    )    ", ECPGt_EOIT, ECPGt_EORT);
#line 20 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 20 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 20 "quote.pgc"


    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
               ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
               ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 22 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 22 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 22 "quote.pgc"

    printf("Standard conforming strings: %s\n", var);

    /* this is a\\b actually */
    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , 'a\\\\\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 26 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 26 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 26 "quote.pgc"

    /* this is a\\b */
    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , E'a\\\\\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 28 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 28 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 28 "quote.pgc"


    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
#line 30 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 30 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 30 "quote.pgc"


    /* this is a\\\\b actually */
    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , 'a\\\\\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 33 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 33 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 33 "quote.pgc"

    /* this is a\\b */
    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , E'a\\\\\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 35 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 35 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 35 "quote.pgc"


    {   ECPGtrans(__LINE__, NULL, "begin transaction ");
#line 37 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 37 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 37 "quote.pgc"

    /* declare C  cursor  for select  *  from \"My_Table\"    */
#line 38 "quote.pgc"


    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C  cursor  for select  *  from \"My_Table\"   ", ECPGt_EOIT, ECPGt_EORT);
#line 40 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 40 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 40 "quote.pgc"


    /* exec sql whenever not found  break ; */
#line 42 "quote.pgc"


    while (true)
    {
        {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT,
                   ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
                   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
                   ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
                   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 46 "quote.pgc"

            if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 46 "quote.pgc"

            if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 46 "quote.pgc"

            if (sqlca.sqlcode < 0) sqlprint();
        }
#line 46 "quote.pgc"

        printf("value: %d %s\n", i, var);
    }

    {   ECPGtrans(__LINE__, NULL, "rollback");
#line 50 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 50 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 50 "quote.pgc"

    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT);
#line 51 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 51 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 51 "quote.pgc"


    {   ECPGdisconnect(__LINE__, "ALL");
#line 53 "quote.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 53 "quote.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 53 "quote.pgc"


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


#line 10 "parser.pgc"
    int item [ 3 ] , ind [ 3 ] , i ;
    /* exec sql end declare section */
#line 11 "parser.pgc"


    ECPGdebug(1, stderr);
    {
        ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
    }
#line 14 "parser.pgc"


    {
        ECPGsetcommit(__LINE__, "on", NULL);
    }
#line 16 "parser.pgc"

    /* exec sql whenever sql_warning  sqlprint ; */
#line 17 "parser.pgc"

    /* exec sql whenever sqlerror  sqlprint ; */
#line 18 "parser.pgc"


    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
#line 20 "parser.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 20 "parser.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 20 "parser.pgc"


    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t select 1 , nullif ( y - 1 , 0 ) from generate_series ( 1 , 3 ) with ordinality as series ( x , y )", ECPGt_EOIT, ECPGt_EORT);
#line 24 "parser.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 24 "parser.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 24 "parser.pgc"


    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT,
               ECPGt_int,(item),(long)1,(long)3,sizeof(int),
               ECPGt_int,(ind),(long)1,(long)3,sizeof(int), ECPGt_EORT);
#line 26 "parser.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 26 "parser.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 26 "parser.pgc"


    for (i=0; i<3; i++)
        printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);

    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter table T alter Item1 type bigint", ECPGt_EOIT, ECPGt_EORT);
#line 31 "parser.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 31 "parser.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 31 "parser.pgc"

    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter table T alter column Item2 set data type smallint", ECPGt_EOIT, ECPGt_EORT);
#line 32 "parser.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 32 "parser.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 32 "parser.pgc"


    {   ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
#line 34 "parser.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 34 "parser.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 34 "parser.pgc"


    {   ECPGdisconnect(__LINE__, "ALL");
#line 36 "parser.pgc"

        if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 36 "parser.pgc"

        if (sqlca.sqlcode < 0) sqlprint();
    }
#line 36 "parser.pgc"


    return 0;
}
int main(void)
{
	/* exec sql begin declare section */
		 
		 
		 
		 
		 
	
#line 49 "test_informix2.pgc"
 int c ;
 
#line 50 "test_informix2.pgc"
 timestamp d ;
 
#line 51 "test_informix2.pgc"
 timestamp e ;
 
#line 52 "test_informix2.pgc"
 timestamp maxd ;
 
#line 53 "test_informix2.pgc"
 char dbname [ 30 ] ;
/* exec sql end declare section */
#line 54 "test_informix2.pgc"


	interval *intvl;

	/* exec sql whenever sqlerror  sqlprint ; */
#line 58 "test_informix2.pgc"


	ECPGdebug(1, stderr);

	strcpy(dbname, "ecpg1_regression");
	{ ECPGconnect(__LINE__, 1, dbname , NULL, NULL , NULL, 0); 
#line 63 "test_informix2.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 63 "test_informix2.pgc"

	sql_check("main", "connect", 0);

	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT);
#line 66 "test_informix2.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 66 "test_informix2.pgc"


	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) )", ECPGt_EOIT, ECPGt_EORT);
#line 68 "test_informix2.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 68 "test_informix2.pgc"

	sql_check("main", "create", 0);

	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )", ECPGt_EOIT, ECPGt_EORT);
#line 73 "test_informix2.pgc"

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

	sql_check("main", "insert", 0);

	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select max ( timestamp ) from history", ECPGt_EOIT, 
	ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 78 "test_informix2.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 78 "test_informix2.pgc"

	sql_check("main", "select max", 100);

	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select customerid , timestamp from history where timestamp = $1  limit 1", 
	ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_int,&(c),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_timestamp,&(d),(long)1,(long)1,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 85 "test_informix2.pgc"

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

	sql_check("main", "select", 0);

	printf("Read in customer %d\n", c);

	intvl = PGTYPESinterval_from_asc("1 day 2 hours 24 minutes 65 seconds", NULL);
	PGTYPEStimestamp_add_interval(&d, intvl, &e);
	free(intvl);
	c++;

	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( $1  , $2  , 'test' , 'test' )", 
	ECPGt_int,&(c),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_timestamp,&(e),(long)1,(long)1,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 97 "test_informix2.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 97 "test_informix2.pgc"

	sql_check("main", "update", 0);

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 100 "test_informix2.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 100 "test_informix2.pgc"


	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table history", ECPGt_EOIT, ECPGt_EORT);
#line 102 "test_informix2.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 102 "test_informix2.pgc"

	sql_check("main", "drop", 0);

	{ ECPGtrans(__LINE__, NULL, "commit");
#line 105 "test_informix2.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 105 "test_informix2.pgc"


	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 107 "test_informix2.pgc"

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

	sql_check("main", "disconnect", 0);

	printf("All OK!\n");

	exit(0);

/*
                 Table "public.history"
    Column    |            Type             | Nullable
--------------+-----------------------------+----------
 customerid   | integer                     | not null
 timestamp    | timestamp without time zone | not null
 action_taken | character(5)                | not null
 narrative    | character varying(100)      |
*/

}
Exemplo n.º 22
0
int main()
{
    /* exec sql begin declare section */
        
        
       
      
         
             
       typedef struct { 
#line 30 "array_of_struct.pgc"
  struct varchar_name_2  { int len; char arr[ 50 ]; }  name ;
 
#line 31 "array_of_struct.pgc"
 int phone ;
 }  customer2 ;

#line 32 "array_of_struct.pgc"

        
       
      
         
             
       
       
      
         
             
       
       
       
    
#line 26 "array_of_struct.pgc"
 customer custs1 [ 10 ] ;
 
#line 27 "array_of_struct.pgc"
 cust_ind inds [ 10 ] ;
 
#line 33 "array_of_struct.pgc"
 customer2 custs2 [ 10 ] ;
 
#line 38 "array_of_struct.pgc"
 struct customer3 { 
#line 36 "array_of_struct.pgc"
  struct varchar_name_3  { int len; char arr[ 50 ]; }  name ;
 
#line 37 "array_of_struct.pgc"
 int phone ;
 } custs3 [ 10 ] ;
 
#line 43 "array_of_struct.pgc"
 struct customer4 { 
#line 41 "array_of_struct.pgc"
  struct varchar_name_4  { int len; char arr[ 50 ]; }  name ;
 
#line 42 "array_of_struct.pgc"
 int phone ;
 } custs4 ;
 
#line 44 "array_of_struct.pgc"
 int r ;
 
#line 45 "array_of_struct.pgc"
  struct varchar_onlyname_5  { int len; char arr[ 50 ]; }  onlyname [ 2 ] ;
/* exec sql end declare section */
#line 46 "array_of_struct.pgc"


    ECPGdebug(1, stderr);

    { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 50 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 50 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 50 "array_of_struct.pgc"


    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table customers ( c varchar ( 50 ) , p int )", ECPGt_EOIT, ECPGt_EORT);
#line 52 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 52 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 52 "array_of_struct.pgc"

    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'John Doe' , '12345' )", ECPGt_EOIT, ECPGt_EORT);
#line 53 "array_of_struct.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 53 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 53 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 53 "array_of_struct.pgc"

    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'Jane Doe' , '67890' )", ECPGt_EOIT, ECPGt_EORT);
#line 54 "array_of_struct.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 54 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 54 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 54 "array_of_struct.pgc"


    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, 
	ECPGt_varchar,&(custs1->name),(long)50,(long)10,sizeof( customer ), 
	ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), 
	ECPGt_int,&(custs1->phone),(long)1,(long)10,sizeof( customer ), 
	ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
#line 56 "array_of_struct.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 56 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 56 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 56 "array_of_struct.pgc"

    printf("custs1:\n");
    for (r = 0; r < 2; r++)
    {
	    printf( "name  - %s\n", custs1[r].name.arr );
	    printf( "phone - %d\n", custs1[r].phone );
    }

    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, 
	ECPGt_varchar,&(custs2->name),(long)50,(long)10,sizeof( customer2 ), 
	ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), 
	ECPGt_int,&(custs2->phone),(long)1,(long)10,sizeof( customer2 ), 
	ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
#line 64 "array_of_struct.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 64 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 64 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 64 "array_of_struct.pgc"

    printf("\ncusts2:\n");
    for (r = 0; r < 2; r++)
    {
	    printf( "name  - %s\n", custs2[r].name.arr );
	    printf( "phone - %d\n", custs2[r].phone );
    }

    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, 
	ECPGt_varchar,&(custs3->name),(long)50,(long)10,sizeof( struct customer3 ), 
	ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), 
	ECPGt_int,&(custs3->phone),(long)1,(long)10,sizeof( struct customer3 ), 
	ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
#line 72 "array_of_struct.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 72 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 72 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 72 "array_of_struct.pgc"

    printf("\ncusts3:\n");
    for (r = 0; r < 2; r++)
    {
	    printf( "name  - %s\n", custs3[r].name.arr );
	    printf( "phone - %d\n", custs3[r].phone );
    }

    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 1", ECPGt_EOIT, 
	ECPGt_varchar,&(custs4.name),(long)50,(long)1,sizeof(struct varchar_name_4), 
	ECPGt_short,&(inds[0].name_ind),(long)1,(long)1,sizeof(short), 
	ECPGt_int,&(custs4.phone),(long)1,(long)1,sizeof(int), 
	ECPGt_short,&(inds[0].phone_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);
#line 80 "array_of_struct.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 80 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 80 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 80 "array_of_struct.pgc"

    printf("\ncusts4:\n");
    printf( "name  - %s\n", custs4.name.arr );
    printf( "phone - %d\n", custs4.phone );

    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select c from customers limit 2", ECPGt_EOIT, 
	ECPGt_varchar,(onlyname),(long)50,(long)2,sizeof(struct varchar_onlyname_5), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 85 "array_of_struct.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 85 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 85 "array_of_struct.pgc"

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

    printf("\nname:\n");
    for (r = 0; r < 2; r++)
    {
	    printf( "name  - %s\n", onlyname[r].arr );
    }

    { ECPGdisconnect(__LINE__, "ALL");
#line 92 "array_of_struct.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 92 "array_of_struct.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 92 "array_of_struct.pgc"


    return( 0 );
}
Exemplo n.º 23
0
int main() {
  /* exec sql begin declare section */
	    
  
#line 9 "insupd.pgc"
 int i1 [ 3 ] , i2 [ 3 ] , i3 [ 3 ] , i4 ;
/* exec sql end declare section */
#line 10 "insupd.pgc"


  ECPGdebug(1, stderr);
  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
#line 13 "insupd.pgc"


  /* exec sql whenever sql_warning  sqlprint ; */
#line 15 "insupd.pgc"

  /* exec sql whenever sqlerror  sqlprint ; */
#line 16 "insupd.pgc"


  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table insupd_test ( a int , b int )", ECPGt_EOIT, ECPGt_EORT);
#line 18 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 18 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 18 "insupd.pgc"


  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 1 , 1 )", ECPGt_EOIT, ECPGt_EORT);
#line 20 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 20 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 20 "insupd.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 2 , 2 )", ECPGt_EOIT, ECPGt_EORT);
#line 21 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 21 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 21 "insupd.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 3 , 3 ) returning a", ECPGt_EOIT, 
	ECPGt_int,&(i4),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 22 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 22 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 22 "insupd.pgc"


  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = a + 1 returning a", ECPGt_EOIT, 
	ECPGt_int,(i3),(long)1,(long)3,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 24 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 24 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 24 "insupd.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set ( a , b ) = ( 5 , 5 ) where a = 4", ECPGt_EOIT, ECPGt_EORT);
#line 25 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 25 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 25 "insupd.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = 4 where a = 3", ECPGt_EOIT, ECPGt_EORT);
#line 26 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 26 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 26 "insupd.pgc"
;

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , b from insupd_test order by a", ECPGt_EOIT, 
	ECPGt_int,(i1),(long)1,(long)3,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,(i2),(long)1,(long)3,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 28 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 28 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 28 "insupd.pgc"


  printf("changes\n%d %d %d %d\n", i3[0], i3[1], i3[2], i4);
  printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);

  { ECPGdisconnect(__LINE__, "ALL");
#line 33 "insupd.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 33 "insupd.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 33 "insupd.pgc"


  return 0;
}
Exemplo n.º 24
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 ;
/* exec sql end declare section */
#line 17 "desc.pgc"


	ECPGdebug(1, stderr);

	ECPGallocate_desc(__LINE__, "indesc");
#line 21 "desc.pgc"

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

	ECPGallocate_desc(__LINE__, "outdesc");
#line 22 "desc.pgc"

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


	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
	ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);

#line 24 "desc.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 24 "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 25 "desc.pgc"

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


	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 27 "desc.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test1 ( a int , b text )", ECPGt_EOIT, ECPGt_EORT);
#line 29 "desc.pgc"

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

	{ ECPGprepare(__LINE__, NULL, 0, "foo1", stmt1);
#line 30 "desc.pgc"

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

	{ ECPGprepare(__LINE__, NULL, 0, "Foo-1", stmt1);
#line 31 "desc.pgc"

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

	{ ECPGprepare(__LINE__, NULL, 0, "foo2", stmt2);
#line 32 "desc.pgc"

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

	{ ECPGprepare(__LINE__, NULL, 0, "foo3", stmt3);
#line 33 "desc.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo1", 
	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 35 "desc.pgc"

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


	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
	ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT);

#line 37 "desc.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 37 "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 38 "desc.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo1", 
	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 40 "desc.pgc"

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


	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
	ECPGt_const,"3",(long)1,(long)1,strlen("3"), ECPGd_EODT);

#line 42 "desc.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 42 "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 43 "desc.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "Foo-1", 
	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 45 "desc.pgc"

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


	{ ECPGdeallocate(__LINE__, 0, NULL, "Foo-1");
#line 47 "desc.pgc"

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


	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
	ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);

#line 49 "desc.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 49 "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 50 "desc.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo2", 
	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_descriptor, "outdesc", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 52 "desc.pgc"

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


	{ ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data,
	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT);

#line 54 "desc.pgc"

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

	printf("output = %s\n", val2output);

	/* declare c1 no scroll cursor for $1 */
#line 57 "desc.pgc"

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "c1", ECPGst_normal, "declare c1 no scroll 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", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 58 "desc.pgc"

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


	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "c1", 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 60 "desc.pgc"

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

	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
		val1output, ind1, val2output, ind2);

	{ ECPGclose(__LINE__, 0, 1, NULL, 0, "c1", ECPGst_normal, "close c1", ECPGt_EOIT, ECPGt_EORT);
#line 64 "desc.pgc"

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


	{ ECPGset_desc_header(__LINE__, "indesc", (int)(1));

#line 66 "desc.pgc"

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

	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
	ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT);

#line 67 "desc.pgc"

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


	/* declare c2 no scroll cursor for $1 */
#line 69 "desc.pgc"

	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "c2", ECPGst_normal, "declare c2 no scroll 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", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 70 "desc.pgc"

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


	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "c2", 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 72 "desc.pgc"

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

	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);

	{ ECPGclose(__LINE__, 0, 1, NULL, 0, "c2", ECPGst_normal, "close c2", ECPGt_EOIT, ECPGt_EORT);
#line 75 "desc.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 75 "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 77 "desc.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 77 "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 80 "desc.pgc"

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

	{ ECPGdeallocate_all(__LINE__, 0, NULL);
#line 81 "desc.pgc"

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

	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 82 "desc.pgc"

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


	ECPGdeallocate_desc(__LINE__, "indesc");
#line 84 "desc.pgc"

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

	ECPGdeallocate_desc(__LINE__, "outdesc");
#line 85 "desc.pgc"

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


	return 0;
}
int
main (void)
{
/* exec sql begin declare section */
		  
		  
		  
		  
		  

#line 15 "describe.pgc"
 char * stmt1 = "SELECT id, t FROM descr_t1" ;
 
#line 16 "describe.pgc"
 char * stmt2 = "SELECT id, t FROM descr_t1 WHERE id = -1" ;
 
#line 17 "describe.pgc"
 int i , count1 , count2 ;
 
#line 18 "describe.pgc"
 char field_name1 [ 30 ] = "not set" ;
 
#line 19 "describe.pgc"
 char field_name2 [ 30 ] = "not set" ;
/* exec sql end declare section */
#line 20 "describe.pgc"


	char msg[128];

	ECPGdebug(1, stderr);

	strcpy(msg, "connect");
	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
#line 27 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 27 "describe.pgc"


	strcpy(msg, "set");
	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
#line 30 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 30 "describe.pgc"


	strcpy(msg, "create");
	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table descr_t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
#line 33 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 33 "describe.pgc"


	strcpy(msg, "insert");
	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
#line 36 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 36 "describe.pgc"

	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
#line 37 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 37 "describe.pgc"

	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
#line 38 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 38 "describe.pgc"

	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
#line 39 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 39 "describe.pgc"


	strcpy(msg, "commit");
	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
#line 42 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 42 "describe.pgc"


	/*
	 * Test DESCRIBE with a query producing tuples.
	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
	 * Informix-compat mode.
	 */

	strcpy(msg, "allocate");
	ECPGallocate_desc(__LINE__, "desc1");
#line 51 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 51 "describe.pgc"

	ECPGallocate_desc(__LINE__, "desc2");
#line 52 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 52 "describe.pgc"


	strcpy(msg, "prepare");
	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
#line 55 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 55 "describe.pgc"


	sqlda1 = sqlda2 = sqlda3 = NULL;

	strcpy(msg, "describe");
	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 60 "describe.pgc"

	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 61 "describe.pgc"


	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 63 "describe.pgc"

	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 64 "describe.pgc"

	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 65 "describe.pgc"


	if (sqlda1 == NULL)
	{
		printf("sqlda1 NULL\n");
		exit(1);
	}

	if (sqlda2 == NULL)
	{
		printf("sqlda2 NULL\n");
		exit(1);
	}

	if (sqlda3 == NULL)
	{
		printf("sqlda3 NULL\n");
		exit(1);
	}

	strcpy(msg, "get descriptor");
	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));

#line 86 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 86 "describe.pgc"

	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));

#line 87 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 87 "describe.pgc"


	if (count1 != count2)
	{
		printf("count1 (%d) != count2 (%d)\n", count1, count2);
		exit(1);
	}

	if (count1 != sqlda1->sqld)
	{
		printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
		exit(1);
	}

	if (count1 != sqlda2->sqld)
	{
		printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
		exit(1);
	}

	if (count1 != sqlda3->sqld)
	{
		printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
		exit(1);
	}

	for (i = 1; i <= count1; i++)
	{
		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 115 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 115 "describe.pgc"

		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 116 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 116 "describe.pgc"

		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
			i, field_name1, field_name2,
			sqlda1->sqlvar[i-1].sqlname,
			sqlda2->sqlvar[i-1].sqlname,
			sqlda3->sqlvar[i-1].sqlname);
	}

	strcpy(msg, "deallocate");
	ECPGdeallocate_desc(__LINE__, "desc1");
#line 126 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 126 "describe.pgc"

	ECPGdeallocate_desc(__LINE__, "desc2");
#line 127 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 127 "describe.pgc"

	free(sqlda1);
	free(sqlda2);
	free(sqlda3);

	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
#line 132 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 132 "describe.pgc"


	/* Test DESCRIBE with a query not producing tuples */

	strcpy(msg, "allocate");
	ECPGallocate_desc(__LINE__, "desc1");
#line 137 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 137 "describe.pgc"

	ECPGallocate_desc(__LINE__, "desc2");
#line 138 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 138 "describe.pgc"


	strcpy(msg, "prepare");
	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
#line 141 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 141 "describe.pgc"


	sqlda1 = sqlda2 = sqlda3 = NULL;

	strcpy(msg, "describe");
	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 146 "describe.pgc"

	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 147 "describe.pgc"


	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 149 "describe.pgc"

	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 150 "describe.pgc"

	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 151 "describe.pgc"


	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
		exit(1);

	strcpy(msg, "get descriptor");
	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));

#line 157 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 157 "describe.pgc"

	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));

#line 158 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 158 "describe.pgc"


	if (!(	count1 == count2 &&
		count1 == sqlda1->sqld &&
		count1 == sqlda2->sqld &&
		count1 == sqlda3->sqld))
		exit(1);

	for (i = 1; i <= count1; i++)
	{
		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 168 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 168 "describe.pgc"

		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);

#line 169 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 169 "describe.pgc"

		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
			i, field_name1, field_name2,
			sqlda1->sqlvar[i-1].sqlname,
			sqlda2->sqlvar[i-1].sqlname,
			sqlda3->sqlvar[i-1].sqlname);
	}

	strcpy(msg, "deallocate");
	ECPGdeallocate_desc(__LINE__, "desc1");
#line 179 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 179 "describe.pgc"

	ECPGdeallocate_desc(__LINE__, "desc2");
#line 180 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);
#line 180 "describe.pgc"

	free(sqlda1);
	free(sqlda2);
	free(sqlda3);

	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
#line 185 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 185 "describe.pgc"


	/* End test */

	strcpy(msg, "drop");
	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table descr_t1", ECPGt_EOIT, ECPGt_EORT);
#line 190 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 190 "describe.pgc"


	strcpy(msg, "commit");
	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
#line 193 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 193 "describe.pgc"


	strcpy(msg, "disconnect");
	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 196 "describe.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 196 "describe.pgc"


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

#line 16 "test1.pgc"
 char db [ 200 ] ;
 
#line 17 "test1.pgc"
 char pw [ 200 ] ;
/* exec sql end declare section */
#line 18 "test1.pgc"


	ECPGdebug(1, stderr);

	{ ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
#line 22 "test1.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
#line 23 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 24 "test1.pgc"
  /* <-- "main" not specified */

	{ ECPGconnect(__LINE__, 0, "connectdb@localhost" , NULL, NULL , "main", 0); }
#line 26 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 27 "test1.pgc"


	{ ECPGconnect(__LINE__, 0, "@localhost" , "connectdb" , NULL , "main", 0); }
#line 29 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "main");}
#line 30 "test1.pgc"


	/* exec sql connect to :@TEMP_PORT@ as main user connectdb;
	exec sql disconnect main; */

	{ ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
#line 35 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 36 "test1.pgc"


	{ ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/" , "connectdb" , NULL , NULL, 0); }
#line 38 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 39 "test1.pgc"


	strcpy(pw, "connectpw");
	strcpy(db, "tcp:postgresql://localhost/connectdb");
	{ ECPGconnect(__LINE__, 0, db , "connectuser" , pw , NULL, 0); }
#line 43 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 44 "test1.pgc"


	{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
#line 46 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 47 "test1.pgc"


	{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb?connect_timeout=14" , "connectuser" , NULL , NULL, 0); }
#line 49 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 50 "test1.pgc"


	/* wrong db */
	{ ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/nonexistant" , "connectuser" , "connectpw" , NULL, 0); }
#line 53 "test1.pgc"

	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 54 "test1.pgc"


	/* wrong port */
	{ ECPGconnect(__LINE__, 0, "tcp:postgresql://127.0.0.1:20/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
#line 57 "test1.pgc"

	/* no disconnect necessary */

	/* wrong password */
	{ ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , "wrongpw" , NULL, 0); }
#line 61 "test1.pgc"

	/* no disconnect necessary */

	return (0);
}
Exemplo n.º 27
0
int
main (void)
{
	MYTYPE		*myvar;
	MYNULLTYPE	*mynullvar;

	char msg[128];

	ECPGdebug(1, stderr);

	strcpy(msg, "connect");
	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 75 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 75 "outofscope.pgc"


	strcpy(msg, "set");
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
#line 78 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 78 "outofscope.pgc"


	strcpy(msg, "create");
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
#line 81 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 81 "outofscope.pgc"


	strcpy(msg, "insert");
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
#line 84 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 84 "outofscope.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
#line 85 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 85 "outofscope.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
#line 86 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 86 "outofscope.pgc"


	strcpy(msg, "commit");
	{ ECPGtrans(__LINE__, NULL, "commit");
#line 89 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 89 "outofscope.pgc"


	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */

	get_var1(&myvar, &mynullvar);
	open_cur1();

	/* exec sql whenever not found  break ; */
#line 96 "outofscope.pgc"


	while (1)
	{
		memset(myvar, 0, sizeof(MYTYPE));
		get_record1();
		if (sqlca.sqlcode == ECPG_NOT_FOUND)
			break;
		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
			myvar->id, mynullvar->id ? " (NULL)" : "",
			myvar->t, mynullvar->t ? " (NULL)" : "",
			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
			myvar->c, mynullvar->c ? " (NULL)" : "");
	}

	close_cur1();

	strcpy(msg, "drop");
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
#line 115 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 115 "outofscope.pgc"


	strcpy(msg, "commit");
	{ ECPGtrans(__LINE__, NULL, "commit");
#line 118 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 118 "outofscope.pgc"


	strcpy(msg, "disconnect"); 
	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 121 "outofscope.pgc"

if (sqlca.sqlcode < 0) exit (1);}
#line 121 "outofscope.pgc"


	return (0);
}
int
main(void)
{
	char *text="error\n";
	char *endptr;
	numeric *num, *nin;
	decimal *dec;
	long l;
	int i, j, k, q, r, count = 0;
	double d;
	numeric **numarr = (numeric **) calloc(1, sizeof(numeric));

	ECPGdebug(1, stderr);

	for (i = 0; nums[i]; i++)
	{
		num = PGTYPESnumeric_from_asc(nums[i], &endptr);
		if (!num) check_errno();
		if (endptr != NULL)
		{
			printf("endptr of %d is not NULL\n", i);
			if (*endptr != '\0')
				printf("*endptr of %d is not \\0\n", i);
		}
		if (!num) continue;

		numarr = realloc(numarr, sizeof(numeric *) * (count + 1));
		numarr[count++] = num;

		text = PGTYPESnumeric_to_asc(num, -1);
		if (!text) check_errno();
		printf("num[%d,1]: %s\n", i, text); free(text);
		text = PGTYPESnumeric_to_asc(num, 0);
		if (!text) check_errno();
		printf("num[%d,2]: %s\n", i, text); free(text);
		text = PGTYPESnumeric_to_asc(num, 1);
		if (!text) check_errno();
		printf("num[%d,3]: %s\n", i, text); free(text);
		text = PGTYPESnumeric_to_asc(num, 2);
		if (!text) check_errno();
		printf("num[%d,4]: %s\n", i, text); free(text);

		nin = PGTYPESnumeric_new();
		text = PGTYPESnumeric_to_asc(nin, 2);
		if (!text) check_errno();
		printf("num[%d,5]: %s\n", i, text); free(text);

		r = PGTYPESnumeric_to_long(num, &l);
		if (r) check_errno();
		printf("num[%d,6]: %ld (r: %d)\n", i, r?0L:l, r);
		if (r == 0)
		{
			r = PGTYPESnumeric_from_long(l, nin);
			if (r) check_errno();
			text = PGTYPESnumeric_to_asc(nin, 2);
			q = PGTYPESnumeric_cmp(num, nin);
			printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
			free(text);
		}

		r = PGTYPESnumeric_to_int(num, &k);
		if (r) check_errno();
		printf("num[%d,8]: %d (r: %d)\n", i, r?0:k, r);
		if (r == 0)
		{
			r = PGTYPESnumeric_from_int(k, nin);
			if (r) check_errno();
			text = PGTYPESnumeric_to_asc(nin, 2);
			q = PGTYPESnumeric_cmp(num, nin);
			printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
			free(text);
		}

		r = PGTYPESnumeric_to_double(num, &d);
		if (r) check_errno();
		printf("num[%d,10]: %g (r: %d)\n", i, r?0.0:d, r);
		/* do not test double to numeric because
		 * - extra digits are different on different architectures
		 * - PGTYPESnumeric_from_double internally calls PGTYPESnumeric_from_asc anyway
		 */

		dec = PGTYPESdecimal_new();
		r = PGTYPESnumeric_to_decimal(num, dec);
		if (r) check_errno();
		/* we have no special routine for outputting decimal, it would
		 * convert to a numeric anyway */
		printf("num[%d,11]: - (r: %d)\n", i, r);
		if (r == 0)
		{
			r = PGTYPESnumeric_from_decimal(dec, nin);
			if (r) check_errno();
			text = PGTYPESnumeric_to_asc(nin, 2);
			q = PGTYPESnumeric_cmp(num, nin);
			printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
			free(text);
		}

		PGTYPESdecimal_free(dec);
		PGTYPESnumeric_free(nin);
		printf("\n");
	}

	for (i = 0; i < count; i++)
	{
		for (j = 0; j < count; j++)
		{
			numeric* a = PGTYPESnumeric_new();
			numeric* s = PGTYPESnumeric_new();
			numeric* m = PGTYPESnumeric_new();
			numeric* d = PGTYPESnumeric_new();
			r = PGTYPESnumeric_add(numarr[i], numarr[j], a);
			if (r)
			{
				check_errno();
				printf("r: %d\n", r);
			}
			else
			{
				text = PGTYPESnumeric_to_asc(a, 10);
				printf("num[a,%d,%d]: %s\n", i, j, text);
				free(text);
			}
			r = PGTYPESnumeric_sub(numarr[i], numarr[j], s);
			if (r)
			{
				check_errno();
				printf("r: %d\n", r);
			}
			else
			{
				text = PGTYPESnumeric_to_asc(s, 10);
				printf("num[s,%d,%d]: %s\n", i, j, text);
				free(text);
			}
			r = PGTYPESnumeric_mul(numarr[i], numarr[j], m);
			if (r)
			{
				check_errno();
				printf("r: %d\n", r);
			}
			else
			{
				text = PGTYPESnumeric_to_asc(m, 10);
				printf("num[m,%d,%d]: %s\n", i, j, text);
				free(text);
			}
			r = PGTYPESnumeric_div(numarr[i], numarr[j], d);
			if (r)
			{
				check_errno();
				printf("r: %d\n", r);
			}
			else
			{
				text = PGTYPESnumeric_to_asc(d, 10);
				printf("num[d,%d,%d]: %s\n", i, j, text);
				free(text);
			}
		}
	}

	for (i = 0; i < count; i++)
	{
		text = PGTYPESnumeric_to_asc(numarr[i], -1);
		printf("%d: %s\n", i, text);
		free(text);
	}

	return (0);
}
Exemplo n.º 29
0
int main()
{
	/* exec sql begin declare section */
		   
		   
	
#line 9 "indicators.pgc"
 int intvar = 5 ;
 
#line 10 "indicators.pgc"
 int nullind = - 1 ;
/* exec sql end declare section */
#line 11 "indicators.pgc"


	ECPGdebug(1,stderr);

	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
#line 15 "indicators.pgc"

	{ ECPGsetcommit(__LINE__, "off", NULL);}
#line 16 "indicators.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table indicator_test ( \"id\" int primary key , \"str\" text not null , val int null )", ECPGt_EOIT, ECPGt_EORT);}
#line 21 "indicators.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit work");}
#line 22 "indicators.pgc"


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 1 , 'Hello' , 0 )", ECPGt_EOIT, ECPGt_EORT);}
#line 24 "indicators.pgc"


	/* use indicator in insert */
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 2 , 'Hi there' , $1  )", 
	ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
	ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
#line 27 "indicators.pgc"

	nullind = 0;
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 3 , 'Good evening' , $1  )", 
	ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
	ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
#line 29 "indicators.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit work");}
#line 30 "indicators.pgc"


	/* use indicators to get information about selects */
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 1", ECPGt_EOIT, 
	ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 33 "indicators.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 2", ECPGt_EOIT, 
	ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
	ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
#line 34 "indicators.pgc"

	printf("intvar: %d, nullind: %d\n", intvar, nullind);
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 3", ECPGt_EOIT, 
	ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
	ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
#line 36 "indicators.pgc"

	printf("intvar: %d, nullind: %d\n", intvar, nullind);

	/* use indicators for update */
	intvar = 5; nullind = -1;
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update indicator_test set val = $1  where id = 1", 
	ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
	ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
#line 41 "indicators.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 1", ECPGt_EOIT, 
	ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
	ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
#line 42 "indicators.pgc"

	printf("intvar: %d, nullind: %d\n", intvar, nullind);

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table indicator_test", ECPGt_EOIT, ECPGt_EORT);}
#line 45 "indicators.pgc"

	{ ECPGtrans(__LINE__, NULL, "commit work");}
#line 46 "indicators.pgc"


	{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 48 "indicators.pgc"

	return 0;
}