#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
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_t * | ECPGget_sqlca (void) |
int | main (void) |
#define ECPGdebug | ( | X, | ||
Y | ||||
) | ECPGdebug((X)+100,(Y)) |
Definition at line 7 of file sql-define.c.
#define PGDLLIMPORT |
Definition at line 19 of file sql-define.c.
#define sqlca (*ECPGget_sqlca()) |
Definition at line 70 of file sql-define.c.
Referenced by main().
#define SQLERRMC_LEN 150 |
Definition at line 23 of file sql-define.c.
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-define.c.
References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_char, ECPGt_EOIT, ECPGt_EORT, ECPGt_int, ECPGt_NO_INDICATOR, i, NULL, sqlca, and sqlprint().
{ /* 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; }