Header And Logo

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

sql-define.c

Go to the documentation of this file.
00001 /* Processed by ecpg (regression mode) */
00002 /* These include files are added by the preprocessor */
00003 #include <ecpglib.h>
00004 #include <ecpgerrno.h>
00005 #include <sqlca.h>
00006 /* End of automatic include section */
00007 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00008 
00009 #line 1 "define.pgc"
00010 
00011 #line 1 "sqlca.h"
00012 #ifndef POSTGRES_SQLCA_H
00013 #define POSTGRES_SQLCA_H
00014 
00015 #ifndef PGDLLIMPORT
00016 #if  defined(WIN32) || defined(__CYGWIN__)
00017 #define PGDLLIMPORT __declspec (dllimport)
00018 #else
00019 #define PGDLLIMPORT
00020 #endif   /* __CYGWIN__ */
00021 #endif   /* PGDLLIMPORT */
00022 
00023 #define SQLERRMC_LEN    150
00024 
00025 #ifdef __cplusplus
00026 extern      "C"
00027 {
00028 #endif
00029 
00030 struct sqlca_t
00031 {
00032     char        sqlcaid[8];
00033     long        sqlabc;
00034     long        sqlcode;
00035     struct
00036     {
00037         int         sqlerrml;
00038         char        sqlerrmc[SQLERRMC_LEN];
00039     }           sqlerrm;
00040     char        sqlerrp[8];
00041     long        sqlerrd[6];
00042     /* Element 0: empty                     */
00043     /* 1: OID of processed tuple if applicable          */
00044     /* 2: number of rows processed              */
00045     /* after an INSERT, UPDATE or               */
00046     /* DELETE statement                 */
00047     /* 3: empty                     */
00048     /* 4: empty                     */
00049     /* 5: empty                     */
00050     char        sqlwarn[8];
00051     /* Element 0: set to 'W' if at least one other is 'W'   */
00052     /* 1: if 'W' at least one character string      */
00053     /* value was truncated when it was          */
00054     /* stored into a host variable.             */
00055 
00056     /*
00057      * 2: if 'W' a (hopefully) non-fatal notice occurred
00058      */ /* 3: empty */
00059     /* 4: empty                     */
00060     /* 5: empty                     */
00061     /* 6: empty                     */
00062     /* 7: empty                     */
00063 
00064     char        sqlstate[5];
00065 };
00066 
00067 struct sqlca_t *ECPGget_sqlca(void);
00068 
00069 #ifndef POSTGRES_ECPG_INTERNAL
00070 #define sqlca (*ECPGget_sqlca())
00071 #endif
00072 
00073 #ifdef __cplusplus
00074 }
00075 #endif
00076 
00077 #endif
00078 
00079 #line 1 "define.pgc"
00080 
00081 
00082 #line 1 "regression.h"
00083 
00084 
00085 
00086 
00087 
00088 
00089 #line 2 "define.pgc"
00090 
00091 
00092 
00093 
00094 
00095 int main(void)
00096 {
00097    /* exec sql begin declare section */
00098       
00099       
00100    
00101 #line 10 "define.pgc"
00102  int i ;
00103  
00104 #line 11 "define.pgc"
00105  char s [ 200 ] ;
00106 /* exec sql end declare section */
00107 #line 12 "define.pgc"
00108 
00109 
00110    ECPGdebug(1, stderr);
00111 
00112    /* exec sql whenever sqlerror  do sqlprint ( ) ; */
00113 #line 16 "define.pgc"
00114 
00115    { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
00116 #line 17 "define.pgc"
00117 
00118 if (sqlca.sqlcode < 0) sqlprint ( );}
00119 #line 17 "define.pgc"
00120 
00121 
00122    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( a int , b text )", ECPGt_EOIT, ECPGt_EORT);
00123 #line 19 "define.pgc"
00124 
00125 if (sqlca.sqlcode < 0) sqlprint ( );}
00126 #line 19 "define.pgc"
00127 
00128    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'abcdef' )", ECPGt_EOIT, ECPGt_EORT);
00129 #line 20 "define.pgc"
00130 
00131 if (sqlca.sqlcode < 0) sqlprint ( );}
00132 #line 20 "define.pgc"
00133 
00134 
00135    
00136    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'defined' )", ECPGt_EOIT, ECPGt_EORT);
00137 #line 23 "define.pgc"
00138 
00139 if (sqlca.sqlcode < 0) sqlprint ( );}
00140 #line 23 "define.pgc"
00141 
00142    
00143 
00144    
00145            
00146    
00147            
00148    
00149    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( null , 'someothervar not defined' )", ECPGt_EOIT, ECPGt_EORT);
00150 #line 31 "define.pgc"
00151 
00152 if (sqlca.sqlcode < 0) sqlprint ( );}
00153 #line 31 "define.pgc"
00154 
00155    
00156 
00157    
00158 
00159    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select 1 , 29 :: text || '-' || 'abcdef'", ECPGt_EOIT, 
00160     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00161     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00162     ECPGt_char,(s),(long)200,(long)1,(200)*sizeof(char), 
00163     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00164 #line 36 "define.pgc"
00165 
00166 if (sqlca.sqlcode < 0) sqlprint ( );}
00167 #line 36 "define.pgc"
00168 
00169 
00170    printf("i: %d, s: %s\n", i, s);
00171 
00172    
00173    
00174    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test values ( 29 , 'no string' )", ECPGt_EOIT, ECPGt_EORT);
00175 #line 42 "define.pgc"
00176 
00177 if (sqlca.sqlcode < 0) sqlprint ( );}
00178 #line 42 "define.pgc"
00179 
00180    
00181 
00182      /* no value */
00183    
00184 
00185    
00186         
00187    
00188         
00189    
00190    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT);
00191 #line 53 "define.pgc"
00192 
00193 if (sqlca.sqlcode < 0) sqlprint ( );}
00194 #line 53 "define.pgc"
00195 
00196    
00197 
00198    { ECPGdisconnect(__LINE__, "CURRENT");
00199 #line 56 "define.pgc"
00200 
00201 if (sqlca.sqlcode < 0) sqlprint ( );}
00202 #line 56 "define.pgc"
00203 
00204    return 0;
00205 }