Esempio n. 1
0
int main ()
{
	int i;
#ifdef WIN32
	HANDLE threads[THREADS];
#else
	pthread_t threads[THREADS];
#endif

	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 69 "prep.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 69 "prep.pgc"

	{ ECPGsetcommit(__LINE__, "on", NULL);
#line 70 "prep.pgc"

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

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table if exists T", ECPGt_EOIT, ECPGt_EORT);
#line 71 "prep.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 71 "prep.pgc"

	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( i int )", ECPGt_EOIT, ECPGt_EORT);
#line 72 "prep.pgc"

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

	{ ECPGdisconnect(__LINE__, "CURRENT");
#line 73 "prep.pgc"

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


#ifdef WIN32
	for (i = 0; i < THREADS; ++i)
	{
		unsigned id;
		threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id);
	}

	WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE);
	for (i = 0; i < THREADS; ++i)
		CloseHandle(threads[i]);
#else
	for (i = 0; i < THREADS; ++i)
		pthread_create(&threads[i], NULL, fn, (void *) (long) i);
	for (i = 0; i < THREADS; ++i)
		pthread_join(threads[i], NULL);
#endif

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

#line 19 "array.pgc"
 int i = 1 , j ;
 
#line 20 "array.pgc"
 int * did = & i ;
 
#line 21 "array.pgc"
 short a [ 10 ] = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ;
 
#line 22 "array.pgc"
 timestamp ts [ 10 ] ;
 
#line 23 "array.pgc"
 date d [ 10 ] ;
 
#line 24 "array.pgc"
 interval in [ 10 ] ;
 
#line 25 "array.pgc"
 numeric n [ 10 ] ;
 
#line 26 "array.pgc"
 char text [ 25 ] = "klmnopqrst" ;
 
#line 27 "array.pgc"
 char * t = ( char * ) malloc ( 11 ) ;
 
#line 28 "array.pgc"
 double f ;
/* exec sql end declare section */
#line 29 "array.pgc"


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

	ECPGdebug(1, stderr);

	for (j = 0; j < 10; j++) {
		char str[20];
		numeric *value;
		interval *inter;

		sprintf(str, "2000-1-1 0%d:00:00", j);
		ts[j] = PGTYPEStimestamp_from_asc(str, NULL);
		sprintf(str, "2000-1-1%d\n", j);
		d[j] = PGTYPESdate_from_asc(str, NULL);
		sprintf(str, "%d hours", j+10);
		inter = PGTYPESinterval_from_asc(str, NULL);
		in[j] = *inter;
		value = PGTYPESnumeric_new();
		PGTYPESnumeric_from_int(j, value);
		n[j] = *value;
	}

        { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); 
#line 53 "array.pgc"

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


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

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


	{ ECPGtrans(__LINE__, NULL, "begin work");
#line 57 "array.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) , ts timestamp [ 10 ] , n numeric [ 10 ] , d date [ 10 ] , inter interval [ 10 ] )", ECPGt_EOIT, ECPGt_EORT);
#line 59 "array.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , $1  , $2  , $3  , $4  )", 
	ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_date,&(d),(long)1,(long)10,sizeof(date), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 61 "array.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 140787.0 , 2 , $1  , $2  , $3  , $4  , $5  , $6  )", 
	ECPGt_short,(a),(long)1,(long)10,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_date,&(d),(long)1,(long)10,sizeof(date), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 63 "array.pgc"

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


	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 14.07 , $1  , $2  , $3  , $4  , $5  , $6  , $7  )", 
	ECPGt_int,&(did),(long)1,(long)0,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_short,(a),(long)1,(long)10,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_date,&(d),(long)1,(long)10,sizeof(date), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 65 "array.pgc"

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


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

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


	for (j = 0; j < 10; j++) {
		ts[j] = PGTYPEStimestamp_from_asc("1900-01-01 00:00:00", NULL);
		d[j] = PGTYPESdate_from_asc("1900-01-01", NULL);
		in[j] = *PGTYPESinterval_new();
		n[j] = *PGTYPESnumeric_new();
	}
	{ ECPGtrans(__LINE__, NULL, "begin work");
#line 75 "array.pgc"

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


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

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


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

	f=140787;
	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , text , ts , n , d , inter from test where f = $1 ", 
	ECPGt_double,&(f),(long)1,(long)1,sizeof(double), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_short,(a),(long)1,(long)10,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_date,&(d),(long)1,(long)10,sizeof(date), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 88 "array.pgc"

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


	for (i = 0; i < 10; i++)
		printf("Found a[%d] = %d ts[%d] = %s n[%d] = %s d[%d] = %s in[%d] = %s\n", i, a[i], i, PGTYPEStimestamp_to_asc(ts[i]), i, PGTYPESnumeric_to_asc(&(n[i]), -1), i, PGTYPESdate_to_asc(d[i]), i, PGTYPESinterval_to_asc(&(in[i])));

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

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

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


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

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

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


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

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


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

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


	free(t);

	return 0;
}
Esempio n. 3
0
static void* fn(void* arg)
#endif
{
	int i;

	/* exec sql begin declare section */
	  
	 
	   
	
#line 39 "prep.pgc"
 int value ;
 
#line 40 "prep.pgc"
 char name [ 100 ] ;
 
#line 41 "prep.pgc"
 char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
/* exec sql end declare section */
#line 42 "prep.pgc"


	value = (long)arg;
	sprintf(name, "Connection: %d", value);

	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , name, 0); 
#line 47 "prep.pgc"

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

	{ ECPGsetcommit(__LINE__, "on", NULL);
#line 48 "prep.pgc"

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

	for (i = 1; i <= REPEATS; ++i)
	{
		{ ECPGprepare(__LINE__, NULL, 0, "i", query);
#line 51 "prep.pgc"

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

		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", 
	ECPGt_int,&(value),(long)1,(long)1,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 52 "prep.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 52 "prep.pgc"

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

	}
	{ ECPGdeallocate(__LINE__, 0, NULL, "i");
#line 54 "prep.pgc"

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

	{ ECPGdisconnect(__LINE__, name);
#line 55 "prep.pgc"

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


	return 0;
}
Esempio n. 4
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;
}
Esempio n. 5
0
static void* fn(void* arg)
#endif
{
	int i;

	/* exec sql begin declare section */
	  
	 
	   
	
#line 39 "alloc.pgc"
 int value ;
 
#line 40 "alloc.pgc"
 char name [ 100 ] ;
 
#line 41 "alloc.pgc"
 char ** r = NULL ;
/* exec sql end declare section */
#line 42 "alloc.pgc"


	value = (long)arg;
	sprintf(name, "Connection: %d", value);

	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , name, 0); 
#line 47 "alloc.pgc"

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

	{ ECPGsetcommit(__LINE__, "on", NULL);
#line 48 "alloc.pgc"

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

	for (i = 1; i <= REPEATS; ++i)
	{
		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select relname from pg_class where relname = 'pg_class'", ECPGt_EOIT, 
	ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 51 "alloc.pgc"

if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 51 "alloc.pgc"

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

		free(r);
		r = NULL;
	}
	{ ECPGdisconnect(__LINE__, name);
#line 55 "alloc.pgc"

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


	return 0;
}
Esempio n. 6
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;
}
Esempio n. 7
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;
}
Esempio n. 8
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);
}