00001
00002
00003 #include <ecpglib.h>
00004 #include <ecpgerrno.h>
00005 #include <sqlca.h>
00006
00007 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00008
00009 #line 1 "indicators.pgc"
00010 #include <stdio.h>
00011
00012
00013 #line 1 "sqlca.h"
00014 #ifndef POSTGRES_SQLCA_H
00015 #define POSTGRES_SQLCA_H
00016
00017 #ifndef PGDLLIMPORT
00018 #if defined(WIN32) || defined(__CYGWIN__)
00019 #define PGDLLIMPORT __declspec (dllimport)
00020 #else
00021 #define PGDLLIMPORT
00022 #endif
00023 #endif
00024
00025 #define SQLERRMC_LEN 150
00026
00027 #ifdef __cplusplus
00028 extern "C"
00029 {
00030 #endif
00031
00032 struct sqlca_t
00033 {
00034 char sqlcaid[8];
00035 long sqlabc;
00036 long sqlcode;
00037 struct
00038 {
00039 int sqlerrml;
00040 char sqlerrmc[SQLERRMC_LEN];
00041 } sqlerrm;
00042 char sqlerrp[8];
00043 long sqlerrd[6];
00044
00045
00046
00047
00048
00049
00050
00051
00052 char sqlwarn[8];
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 char sqlstate[5];
00067 };
00068
00069 struct sqlca_t *ECPGget_sqlca(void);
00070
00071 #ifndef POSTGRES_ECPG_INTERNAL
00072 #define sqlca (*ECPGget_sqlca())
00073 #endif
00074
00075 #ifdef __cplusplus
00076 }
00077 #endif
00078
00079 #endif
00080
00081 #line 3 "indicators.pgc"
00082
00083
00084 #line 1 "regression.h"
00085
00086
00087
00088
00089
00090
00091 #line 4 "indicators.pgc"
00092
00093
00094 int main()
00095 {
00096
00097
00098
00099
00100 #line 9 "indicators.pgc"
00101 int intvar = 5 ;
00102
00103 #line 10 "indicators.pgc"
00104 int nullind = - 1 ;
00105
00106 #line 11 "indicators.pgc"
00107
00108
00109 ECPGdebug(1,stderr);
00110
00111 { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
00112 #line 15 "indicators.pgc"
00113
00114 { ECPGsetcommit(__LINE__, "off", NULL);}
00115 #line 16 "indicators.pgc"
00116
00117
00118 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table indicator_test ( \"id\" int primary key , \"str\" text not null , val int null )", ECPGt_EOIT, ECPGt_EORT);}
00119 #line 21 "indicators.pgc"
00120
00121 { ECPGtrans(__LINE__, NULL, "commit work");}
00122 #line 22 "indicators.pgc"
00123
00124
00125 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 1 , 'Hello' , 0 )", ECPGt_EOIT, ECPGt_EORT);}
00126 #line 24 "indicators.pgc"
00127
00128
00129
00130 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 2 , 'Hi there' , $1 )",
00131 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
00132 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
00133 #line 27 "indicators.pgc"
00134
00135 nullind = 0;
00136 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 3 , 'Good evening' , $1 )",
00137 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
00138 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
00139 #line 29 "indicators.pgc"
00140
00141 { ECPGtrans(__LINE__, NULL, "commit work");}
00142 #line 30 "indicators.pgc"
00143
00144
00145
00146 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 1", ECPGt_EOIT,
00147 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
00148 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00149 #line 33 "indicators.pgc"
00150
00151 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 2", ECPGt_EOIT,
00152 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
00153 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
00154 #line 34 "indicators.pgc"
00155
00156 printf("intvar: %d, nullind: %d\n", intvar, nullind);
00157 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 3", ECPGt_EOIT,
00158 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
00159 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
00160 #line 36 "indicators.pgc"
00161
00162 printf("intvar: %d, nullind: %d\n", intvar, nullind);
00163
00164
00165 intvar = 5; nullind = -1;
00166 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update indicator_test set val = $1 where id = 1",
00167 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
00168 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
00169 #line 41 "indicators.pgc"
00170
00171 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 1", ECPGt_EOIT,
00172 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
00173 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
00174 #line 42 "indicators.pgc"
00175
00176 printf("intvar: %d, nullind: %d\n", intvar, nullind);
00177
00178 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table indicator_test", ECPGt_EOIT, ECPGt_EORT);}
00179 #line 45 "indicators.pgc"
00180
00181 { ECPGtrans(__LINE__, NULL, "commit work");}
00182 #line 46 "indicators.pgc"
00183
00184
00185 { ECPGdisconnect(__LINE__, "CURRENT");}
00186 #line 48 "indicators.pgc"
00187
00188 return 0;
00189 }