Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Functions

sql-code100.c File Reference

#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdio.h>
Include dependency graph for sql-code100.c:

Go to the source code of this file.

Data Structures

struct  sqlca_t

Defines

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
#define PGDLLIMPORT
#define SQLERRMC_LEN   150
#define sqlca   (*ECPGget_sqlca())

Functions

struct sqlca_tECPGget_sqlca (void)
int main ()

Define Documentation

#define ECPGdebug (   X,
  Y 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file sql-code100.c.

#define PGDLLIMPORT

Definition at line 19 of file sql-code100.c.

#define sqlca   (*ECPGget_sqlca())

Definition at line 70 of file sql-code100.c.

Referenced by main().

#define SQLERRMC_LEN   150

Definition at line 23 of file sql-code100.c.


Function Documentation

struct sqlca_t* ECPGget_sqlca ( void   )  [read]

Definition at line 135 of file misc.c.

{
#ifdef ENABLE_THREAD_SAFETY
    struct sqlca_t *sqlca;

    pthread_once(&sqlca_key_once, ecpg_sqlca_key_init);

    sqlca = pthread_getspecific(sqlca_key);
    if (sqlca == NULL)
    {
        sqlca = malloc(sizeof(struct sqlca_t));
        ecpg_init_sqlca(sqlca);
        pthread_setspecific(sqlca_key, sqlca);
    }
    return (sqlca);
#else
    return (&sqlca);
#endif
}

int main ( void   ) 

Definition at line 95 of file sql-code100.c.

References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_EOIT, ECPGt_EORT, ECPGt_int, ECPGt_NO_INDICATOR, ECPGtrans(), NULL, and sqlca.

{  /* 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;
}