Header And Logo

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

preproc-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 #include <stdlib.h>
00011 #include <string.h>
00012 #include <stdlib.h>
00013 #include <stdio.h>
00014 
00015 
00016 #line 1 "regression.h"
00017 
00018 
00019 
00020 
00021 
00022 
00023 #line 6 "define.pgc"
00024 
00025 
00026 /* exec sql whenever sqlerror  sqlprint ; */
00027 #line 8 "define.pgc"
00028 
00029 
00030 
00031 
00032 
00033 /* exec sql type intarray is int [ 6 ] */
00034 #line 13 "define.pgc"
00035 
00036 typedef int intarray[ 6];
00037 
00038 int
00039 main(void)
00040 {
00041 /* exec sql begin declare section */
00042 
00043        typedef char  string [ 8 ];
00044 
00045 #line 21 "define.pgc"
00046 
00047      
00048        
00049          
00050 
00051 #line 22 "define.pgc"
00052  intarray amount ;
00053  
00054 #line 23 "define.pgc"
00055  char name [ 6 ] [ 8 ] ;
00056  
00057 #line 24 "define.pgc"
00058  char letter [ 6 ] [ 1 ] ;
00059  
00060 #if 0
00061  
00062 #line 26 "define.pgc"
00063  int not_used ;
00064  
00065 #endif
00066 /* exec sql end declare section */
00067 #line 29 "define.pgc"
00068 
00069     int i,j;
00070 
00071     ECPGdebug(1, stderr);
00072 
00073     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
00074 #line 34 "define.pgc"
00075 
00076 if (sqlca.sqlcode < 0) sqlprint();}
00077 #line 34 "define.pgc"
00078 
00079 
00080     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )", ECPGt_EOIT, ECPGt_EORT);
00081 #line 36 "define.pgc"
00082 
00083 if (sqlca.sqlcode < 0) sqlprint();}
00084 #line 36 "define.pgc"
00085 
00086     { ECPGtrans(__LINE__, NULL, "commit");
00087 #line 37 "define.pgc"
00088 
00089 if (sqlca.sqlcode < 0) sqlprint();}
00090 #line 37 "define.pgc"
00091 
00092 
00093     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' )", ECPGt_EOIT, ECPGt_EORT);
00094 #line 39 "define.pgc"
00095 
00096 if (sqlca.sqlcode < 0) sqlprint();}
00097 #line 39 "define.pgc"
00098 
00099     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' )", ECPGt_EOIT, ECPGt_EORT);
00100 #line 40 "define.pgc"
00101 
00102 if (sqlca.sqlcode < 0) sqlprint();}
00103 #line 40 "define.pgc"
00104 
00105     { ECPGtrans(__LINE__, NULL, "commit");
00106 #line 41 "define.pgc"
00107 
00108 if (sqlca.sqlcode < 0) sqlprint();}
00109 #line 41 "define.pgc"
00110 
00111 
00112     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT, 
00113     ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char), 
00114     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00115     ECPGt_int,(amount),(long)1,(long)6,sizeof(int), 
00116     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00117     ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char), 
00118     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00119 #line 43 "define.pgc"
00120 
00121 if (sqlca.sqlcode < 0) sqlprint();}
00122 #line 43 "define.pgc"
00123 
00124 
00125     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
00126     {
00127         /* exec sql begin declare section */
00128             
00129            
00130         
00131 #line 48 "define.pgc"
00132  char n [ 8 ] , l = letter [ i ] [ 0 ] ;
00133  
00134 #line 49 "define.pgc"
00135  int a = amount [ i ] ;
00136 /* exec sql end declare section */
00137 #line 50 "define.pgc"
00138 
00139 
00140         strncpy(n, name[i],  8);
00141         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
00142     }
00143 
00144     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
00145 #line 56 "define.pgc"
00146 
00147 if (sqlca.sqlcode < 0) sqlprint();}
00148 #line 56 "define.pgc"
00149 
00150     { ECPGtrans(__LINE__, NULL, "commit");
00151 #line 57 "define.pgc"
00152 
00153 if (sqlca.sqlcode < 0) sqlprint();}
00154 #line 57 "define.pgc"
00155 
00156     { ECPGdisconnect(__LINE__, "CURRENT");
00157 #line 58 "define.pgc"
00158 
00159 if (sqlca.sqlcode < 0) sqlprint();}
00160 #line 58 "define.pgc"
00161 
00162 
00163     return (0);
00164 }