Header And Logo

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

preproc-array_of_struct.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 "array_of_struct.pgc"
00010 #include <stdio.h>
00011 
00012 
00013 #line 1 "regression.h"
00014 
00015 
00016 
00017 
00018 
00019 
00020 #line 3 "array_of_struct.pgc"
00021 
00022 
00023 /* exec sql whenever sqlerror  sqlprint ; */
00024 #line 5 "array_of_struct.pgc"
00025 
00026 /* exec sql whenever sql_warning  sqlprint ; */
00027 #line 6 "array_of_struct.pgc"
00028 
00029 /* exec sql whenever not found  sqlprint ; */
00030 #line 7 "array_of_struct.pgc"
00031 
00032 
00033 typedef  struct { 
00034 #line 12 "array_of_struct.pgc"
00035   struct varchar_1  { int len; char arr[ 50 ]; }  name ;
00036  
00037 #line 13 "array_of_struct.pgc"
00038  int phone ;
00039  } customer ;
00040 #line 14 "array_of_struct.pgc"
00041 
00042 
00043 typedef  struct ind { 
00044 #line 19 "array_of_struct.pgc"
00045  short name_ind ;
00046  
00047 #line 20 "array_of_struct.pgc"
00048  short phone_ind ;
00049  } cust_ind ;
00050 #line 21 "array_of_struct.pgc"
00051 
00052 
00053 int main()
00054 {
00055     /* exec sql begin declare section */
00056         
00057         
00058        
00059       
00060          
00061              
00062        typedef struct { 
00063 #line 30 "array_of_struct.pgc"
00064   struct varchar_2  { int len; char arr[ 50 ]; }  name ;
00065  
00066 #line 31 "array_of_struct.pgc"
00067  int phone ;
00068  }  customer2 ;
00069 
00070 #line 32 "array_of_struct.pgc"
00071 
00072         
00073        
00074       
00075          
00076              
00077        
00078        
00079       
00080          
00081              
00082        
00083        
00084        
00085     
00086 #line 26 "array_of_struct.pgc"
00087  customer custs1 [ 10 ] ;
00088  
00089 #line 27 "array_of_struct.pgc"
00090  cust_ind inds [ 10 ] ;
00091  
00092 #line 33 "array_of_struct.pgc"
00093  customer2 custs2 [ 10 ] ;
00094  
00095 #line 38 "array_of_struct.pgc"
00096  struct customer3 { 
00097 #line 36 "array_of_struct.pgc"
00098   struct varchar_3  { int len; char arr[ 50 ]; }  name ;
00099  
00100 #line 37 "array_of_struct.pgc"
00101  int phone ;
00102  } custs3 [ 10 ] ;
00103  
00104 #line 43 "array_of_struct.pgc"
00105  struct customer4 { 
00106 #line 41 "array_of_struct.pgc"
00107   struct varchar_4  { int len; char arr[ 50 ]; }  name ;
00108  
00109 #line 42 "array_of_struct.pgc"
00110  int phone ;
00111  } custs4 ;
00112  
00113 #line 44 "array_of_struct.pgc"
00114  int r ;
00115  
00116 #line 45 "array_of_struct.pgc"
00117   struct varchar_5  { int len; char arr[ 50 ]; }  onlyname [ 2 ] ;
00118 /* exec sql end declare section */
00119 #line 46 "array_of_struct.pgc"
00120 
00121 
00122     ECPGdebug(1, stderr);
00123 
00124     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
00125 #line 50 "array_of_struct.pgc"
00126 
00127 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00128 #line 50 "array_of_struct.pgc"
00129 
00130 if (sqlca.sqlcode < 0) sqlprint();}
00131 #line 50 "array_of_struct.pgc"
00132 
00133 
00134     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table customers ( c varchar ( 50 ) , p int )", ECPGt_EOIT, ECPGt_EORT);
00135 #line 52 "array_of_struct.pgc"
00136 
00137 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00138 #line 52 "array_of_struct.pgc"
00139 
00140 if (sqlca.sqlcode < 0) sqlprint();}
00141 #line 52 "array_of_struct.pgc"
00142 
00143     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'John Doe' , '12345' )", ECPGt_EOIT, ECPGt_EORT);
00144 #line 53 "array_of_struct.pgc"
00145 
00146 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
00147 #line 53 "array_of_struct.pgc"
00148 
00149 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00150 #line 53 "array_of_struct.pgc"
00151 
00152 if (sqlca.sqlcode < 0) sqlprint();}
00153 #line 53 "array_of_struct.pgc"
00154 
00155     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'Jane Doe' , '67890' )", ECPGt_EOIT, ECPGt_EORT);
00156 #line 54 "array_of_struct.pgc"
00157 
00158 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
00159 #line 54 "array_of_struct.pgc"
00160 
00161 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00162 #line 54 "array_of_struct.pgc"
00163 
00164 if (sqlca.sqlcode < 0) sqlprint();}
00165 #line 54 "array_of_struct.pgc"
00166 
00167 
00168     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, 
00169     ECPGt_varchar,&(custs1->name),(long)50,(long)10,sizeof( customer ), 
00170     ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), 
00171     ECPGt_int,&(custs1->phone),(long)1,(long)10,sizeof( customer ), 
00172     ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
00173 #line 56 "array_of_struct.pgc"
00174 
00175 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
00176 #line 56 "array_of_struct.pgc"
00177 
00178 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00179 #line 56 "array_of_struct.pgc"
00180 
00181 if (sqlca.sqlcode < 0) sqlprint();}
00182 #line 56 "array_of_struct.pgc"
00183 
00184     printf("custs1:\n");
00185     for (r = 0; r < 2; r++)
00186     {
00187         printf( "name  - %s\n", custs1[r].name.arr );
00188         printf( "phone - %d\n", custs1[r].phone );
00189     }
00190 
00191     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, 
00192     ECPGt_varchar,&(custs2->name),(long)50,(long)10,sizeof( customer2 ), 
00193     ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), 
00194     ECPGt_int,&(custs2->phone),(long)1,(long)10,sizeof( customer2 ), 
00195     ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
00196 #line 64 "array_of_struct.pgc"
00197 
00198 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
00199 #line 64 "array_of_struct.pgc"
00200 
00201 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00202 #line 64 "array_of_struct.pgc"
00203 
00204 if (sqlca.sqlcode < 0) sqlprint();}
00205 #line 64 "array_of_struct.pgc"
00206 
00207     printf("\ncusts2:\n");
00208     for (r = 0; r < 2; r++)
00209     {
00210         printf( "name  - %s\n", custs2[r].name.arr );
00211         printf( "phone - %d\n", custs2[r].phone );
00212     }
00213 
00214     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT, 
00215     ECPGt_varchar,&(custs3->name),(long)50,(long)10,sizeof( struct customer3 ), 
00216     ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ), 
00217     ECPGt_int,&(custs3->phone),(long)1,(long)10,sizeof( struct customer3 ), 
00218     ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
00219 #line 72 "array_of_struct.pgc"
00220 
00221 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
00222 #line 72 "array_of_struct.pgc"
00223 
00224 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00225 #line 72 "array_of_struct.pgc"
00226 
00227 if (sqlca.sqlcode < 0) sqlprint();}
00228 #line 72 "array_of_struct.pgc"
00229 
00230     printf("\ncusts3:\n");
00231     for (r = 0; r < 2; r++)
00232     {
00233         printf( "name  - %s\n", custs3[r].name.arr );
00234         printf( "phone - %d\n", custs3[r].phone );
00235     }
00236 
00237     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 1", ECPGt_EOIT, 
00238     ECPGt_varchar,&(custs4.name),(long)50,(long)1,sizeof(struct varchar_4), 
00239     ECPGt_short,&(inds[0].name_ind),(long)1,(long)1,sizeof(short), 
00240     ECPGt_int,&(custs4.phone),(long)1,(long)1,sizeof(int), 
00241     ECPGt_short,&(inds[0].phone_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);
00242 #line 80 "array_of_struct.pgc"
00243 
00244 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
00245 #line 80 "array_of_struct.pgc"
00246 
00247 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00248 #line 80 "array_of_struct.pgc"
00249 
00250 if (sqlca.sqlcode < 0) sqlprint();}
00251 #line 80 "array_of_struct.pgc"
00252 
00253     printf("\ncusts4:\n");
00254     printf( "name  - %s\n", custs4.name.arr );
00255     printf( "phone - %d\n", custs4.phone );
00256 
00257     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select c from customers limit 2", ECPGt_EOIT, 
00258     ECPGt_varchar,(onlyname),(long)50,(long)2,sizeof(struct varchar_5), 
00259     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00260 #line 85 "array_of_struct.pgc"
00261 
00262 if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
00263 #line 85 "array_of_struct.pgc"
00264 
00265 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00266 #line 85 "array_of_struct.pgc"
00267 
00268 if (sqlca.sqlcode < 0) sqlprint();}
00269 #line 85 "array_of_struct.pgc"
00270 
00271     printf("\nname:\n");
00272     for (r = 0; r < 2; r++)
00273     {
00274         printf( "name  - %s\n", onlyname[r].arr );
00275     }
00276 
00277     { ECPGdisconnect(__LINE__, "ALL");
00278 #line 92 "array_of_struct.pgc"
00279 
00280 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00281 #line 92 "array_of_struct.pgc"
00282 
00283 if (sqlca.sqlcode < 0) sqlprint();}
00284 #line 92 "array_of_struct.pgc"
00285 
00286 
00287     return( 0 );
00288 }