Header And Logo

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

sql-dynalloc.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 "dynalloc.pgc"
00010 #include <stdio.h>
00011 
00012 #line 1 "sqlca.h"
00013 #ifndef POSTGRES_SQLCA_H
00014 #define POSTGRES_SQLCA_H
00015 
00016 #ifndef PGDLLIMPORT
00017 #if  defined(WIN32) || defined(__CYGWIN__)
00018 #define PGDLLIMPORT __declspec (dllimport)
00019 #else
00020 #define PGDLLIMPORT
00021 #endif   /* __CYGWIN__ */
00022 #endif   /* PGDLLIMPORT */
00023 
00024 #define SQLERRMC_LEN    150
00025 
00026 #ifdef __cplusplus
00027 extern      "C"
00028 {
00029 #endif
00030 
00031 struct sqlca_t
00032 {
00033     char        sqlcaid[8];
00034     long        sqlabc;
00035     long        sqlcode;
00036     struct
00037     {
00038         int         sqlerrml;
00039         char        sqlerrmc[SQLERRMC_LEN];
00040     }           sqlerrm;
00041     char        sqlerrp[8];
00042     long        sqlerrd[6];
00043     /* Element 0: empty                     */
00044     /* 1: OID of processed tuple if applicable          */
00045     /* 2: number of rows processed              */
00046     /* after an INSERT, UPDATE or               */
00047     /* DELETE statement                 */
00048     /* 3: empty                     */
00049     /* 4: empty                     */
00050     /* 5: empty                     */
00051     char        sqlwarn[8];
00052     /* Element 0: set to 'W' if at least one other is 'W'   */
00053     /* 1: if 'W' at least one character string      */
00054     /* value was truncated when it was          */
00055     /* stored into a host variable.             */
00056 
00057     /*
00058      * 2: if 'W' a (hopefully) non-fatal notice occurred
00059      */ /* 3: empty */
00060     /* 4: empty                     */
00061     /* 5: empty                     */
00062     /* 6: empty                     */
00063     /* 7: empty                     */
00064 
00065     char        sqlstate[5];
00066 };
00067 
00068 struct sqlca_t *ECPGget_sqlca(void);
00069 
00070 #ifndef POSTGRES_ECPG_INTERNAL
00071 #define sqlca (*ECPGget_sqlca())
00072 #endif
00073 
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077 
00078 #endif
00079 
00080 #line 2 "dynalloc.pgc"
00081 
00082 #include <stdlib.h>
00083 
00084 #line 1 "regression.h"
00085 
00086 
00087 
00088 
00089 
00090 
00091 #line 4 "dynalloc.pgc"
00092 
00093 
00094 int main(void)
00095 {
00096    /* exec sql begin declare section */
00097         
00098      
00099     
00100     
00101     
00102     
00103     
00104 /*   char **d8=0; */
00105     
00106     
00107     
00108     
00109     
00110     
00111     
00112     
00113 /*   int *i8=0; */
00114     
00115    
00116 #line 9 "dynalloc.pgc"
00117  int * d1 = 0 ;
00118  
00119 #line 10 "dynalloc.pgc"
00120  double * d2 = 0 ;
00121  
00122 #line 11 "dynalloc.pgc"
00123  char ** d3 = 0 ;
00124  
00125 #line 12 "dynalloc.pgc"
00126  char ** d4 = 0 ;
00127  
00128 #line 13 "dynalloc.pgc"
00129  char ** d5 = 0 ;
00130  
00131 #line 14 "dynalloc.pgc"
00132  char ** d6 = 0 ;
00133  
00134 #line 15 "dynalloc.pgc"
00135  char ** d7 = 0 ;
00136  
00137 #line 17 "dynalloc.pgc"
00138  char ** d9 = 0 ;
00139  
00140 #line 18 "dynalloc.pgc"
00141  int * i1 = 0 ;
00142  
00143 #line 19 "dynalloc.pgc"
00144  int * i2 = 0 ;
00145  
00146 #line 20 "dynalloc.pgc"
00147  int * i3 = 0 ;
00148  
00149 #line 21 "dynalloc.pgc"
00150  int * i4 = 0 ;
00151  
00152 #line 22 "dynalloc.pgc"
00153  int * i5 = 0 ;
00154  
00155 #line 23 "dynalloc.pgc"
00156  int * i6 = 0 ;
00157  
00158 #line 24 "dynalloc.pgc"
00159  int * i7 = 0 ;
00160  
00161 #line 26 "dynalloc.pgc"
00162  int * i9 = 0 ;
00163 /* exec sql end declare section */
00164 #line 27 "dynalloc.pgc"
00165 
00166    int i;
00167 
00168    ECPGdebug(1, stderr);
00169 
00170    /* exec sql whenever sqlerror  do sqlprint ( ) ; */
00171 #line 32 "dynalloc.pgc"
00172 
00173    { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
00174 #line 33 "dynalloc.pgc"
00175 
00176 if (sqlca.sqlcode < 0) sqlprint ( );}
00177 #line 33 "dynalloc.pgc"
00178 
00179 
00180    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to mdy", ECPGt_EOIT, ECPGt_EORT);
00181 #line 35 "dynalloc.pgc"
00182 
00183 if (sqlca.sqlcode < 0) sqlprint ( );}
00184 #line 35 "dynalloc.pgc"
00185 
00186 
00187    { 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);
00188 #line 37 "dynalloc.pgc"
00189 
00190 if (sqlca.sqlcode < 0) sqlprint ( );}
00191 #line 37 "dynalloc.pgc"
00192 
00193    { 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);
00194 #line 38 "dynalloc.pgc"
00195 
00196 if (sqlca.sqlcode < 0) sqlprint ( );}
00197 #line 38 "dynalloc.pgc"
00198 
00199    { 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);
00200 #line 39 "dynalloc.pgc"
00201 
00202 if (sqlca.sqlcode < 0) sqlprint ( );}
00203 #line 39 "dynalloc.pgc"
00204 
00205 
00206    ECPGallocate_desc(__LINE__, "mydesc");
00207 #line 41 "dynalloc.pgc"
00208 
00209 if (sqlca.sqlcode < 0) sqlprint ( );
00210 #line 41 "dynalloc.pgc"
00211 
00212    { 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, 
00213     ECPGt_descriptor, "mydesc", 0L, 0L, 0L, 
00214     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00215 #line 42 "dynalloc.pgc"
00216 
00217 if (sqlca.sqlcode < 0) sqlprint ( );}
00218 #line 42 "dynalloc.pgc"
00219 
00220    { ECPGget_desc(__LINE__, "mydesc", 1,ECPGd_indicator,
00221     ECPGt_int,&(i1),(long)1,(long)0,sizeof(int), ECPGd_data,
00222     ECPGt_int,&(d1),(long)1,(long)0,sizeof(int), ECPGd_EODT);
00223 
00224 #line 43 "dynalloc.pgc"
00225 
00226 if (sqlca.sqlcode < 0) sqlprint ( );}
00227 #line 43 "dynalloc.pgc"
00228 
00229    { ECPGget_desc(__LINE__, "mydesc", 2,ECPGd_indicator,
00230     ECPGt_int,&(i2),(long)1,(long)0,sizeof(int), ECPGd_data,
00231     ECPGt_double,&(d2),(long)1,(long)0,sizeof(double), ECPGd_EODT);
00232 
00233 #line 44 "dynalloc.pgc"
00234 
00235 if (sqlca.sqlcode < 0) sqlprint ( );}
00236 #line 44 "dynalloc.pgc"
00237 
00238    { ECPGget_desc(__LINE__, "mydesc", 3,ECPGd_indicator,
00239     ECPGt_int,&(i3),(long)1,(long)0,sizeof(int), ECPGd_data,
00240     ECPGt_char,&(d3),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
00241 
00242 #line 45 "dynalloc.pgc"
00243 
00244 if (sqlca.sqlcode < 0) sqlprint ( );}
00245 #line 45 "dynalloc.pgc"
00246 
00247    { ECPGget_desc(__LINE__, "mydesc", 4,ECPGd_indicator,
00248     ECPGt_int,&(i4),(long)1,(long)0,sizeof(int), ECPGd_data,
00249     ECPGt_char,&(d4),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
00250 
00251 #line 46 "dynalloc.pgc"
00252 
00253 if (sqlca.sqlcode < 0) sqlprint ( );}
00254 #line 46 "dynalloc.pgc"
00255 
00256    { ECPGget_desc(__LINE__, "mydesc", 5,ECPGd_indicator,
00257     ECPGt_int,&(i5),(long)1,(long)0,sizeof(int), ECPGd_data,
00258     ECPGt_char,&(d5),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
00259 
00260 #line 47 "dynalloc.pgc"
00261 
00262 if (sqlca.sqlcode < 0) sqlprint ( );}
00263 #line 47 "dynalloc.pgc"
00264 
00265    { ECPGget_desc(__LINE__, "mydesc", 6,ECPGd_indicator,
00266     ECPGt_int,&(i6),(long)1,(long)0,sizeof(int), ECPGd_data,
00267     ECPGt_char,&(d6),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
00268 
00269 #line 48 "dynalloc.pgc"
00270 
00271 if (sqlca.sqlcode < 0) sqlprint ( );}
00272 #line 48 "dynalloc.pgc"
00273 
00274    { ECPGget_desc(__LINE__, "mydesc", 7,ECPGd_indicator,
00275     ECPGt_int,&(i7),(long)1,(long)0,sizeof(int), ECPGd_data,
00276     ECPGt_char,&(d7),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
00277 
00278 #line 49 "dynalloc.pgc"
00279 
00280 if (sqlca.sqlcode < 0) sqlprint ( );}
00281 #line 49 "dynalloc.pgc"
00282 
00283    /* skip box for now */
00284    /* exec sql get descriptor mydesc value 8 :d8=DATA, :i8=INDICATOR; */
00285    { ECPGget_desc(__LINE__, "mydesc", 9,ECPGd_indicator,
00286     ECPGt_int,&(i9),(long)1,(long)0,sizeof(int), ECPGd_data,
00287     ECPGt_char,&(d9),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
00288 
00289 #line 52 "dynalloc.pgc"
00290 
00291 if (sqlca.sqlcode < 0) sqlprint ( );}
00292 #line 52 "dynalloc.pgc"
00293 
00294 
00295    printf("Result:\n");
00296    for (i=0;i<sqlca.sqlerrd[2];++i)
00297    {
00298       if (i1[i]) printf("NULL, ");
00299       else printf("%d, ",d1[i]);
00300 
00301       if (i2[i]) printf("NULL, ");
00302       else printf("%f, ",d2[i]);
00303 
00304       if (i3[i]) printf("NULL, ");
00305       else printf("'%s', ",d3[i]);
00306 
00307       if (i4[i]) printf("NULL, ");
00308       else printf("'%s', ",d4[i]);
00309 
00310       if (i5[i]) printf("NULL, ");
00311       else printf("'%s', ",d5[i]);
00312 
00313       if (i6[i]) printf("NULL, ");
00314       else printf("'%s', ",d6[i]);
00315 
00316       if (i7[i]) printf("NULL, ");
00317       else printf("'%s', ",d7[i]);
00318 
00319       if (i9[i]) printf("NULL, ");
00320       else printf("'%s', ",d9[i]);
00321 
00322       printf("\n");
00323    }
00324    ECPGfree_auto_mem();
00325    printf("\n");
00326 
00327    ECPGdeallocate_desc(__LINE__, "mydesc");
00328 #line 86 "dynalloc.pgc"
00329 
00330 if (sqlca.sqlcode < 0) sqlprint ( );
00331 #line 86 "dynalloc.pgc"
00332 
00333    { ECPGdisconnect(__LINE__, "CURRENT");
00334 #line 87 "dynalloc.pgc"
00335 
00336 if (sqlca.sqlcode < 0) sqlprint ( );}
00337 #line 87 "dynalloc.pgc"
00338 
00339    return 0;
00340 }