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 "code100.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
00021 #endif
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
00043
00044
00045
00046
00047
00048
00049
00050 char sqlwarn[8];
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
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 "code100.pgc"
00080
00081 #include <stdio.h>
00082
00083
00084 #line 1 "regression.h"
00085
00086
00087
00088
00089
00090
00091 #line 4 "code100.pgc"
00092
00093
00094
00095 int main()
00096 {
00097
00098
00099 #line 9 "code100.pgc"
00100 int index ;
00101
00102 #line 10 "code100.pgc"
00103
00104
00105
00106 ECPGdebug(1,stderr);
00107
00108 { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
00109 #line 15 "code100.pgc"
00110
00111 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00112
00113 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( \"index\" numeric ( 3 ) primary key , \"payload\" int4 not null )", ECPGt_EOIT, ECPGt_EORT);}
00114 #line 20 "code100.pgc"
00115
00116 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00117 { ECPGtrans(__LINE__, NULL, "commit work");}
00118 #line 22 "code100.pgc"
00119
00120 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00121
00122 for (index=0;index<10;++index)
00123 { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( payload , index ) values ( 0 , $1 )",
00124 ECPGt_int,&(index),(long)1,(long)1,sizeof(int),
00125 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
00126 #line 28 "code100.pgc"
00127
00128 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00129 }
00130 { ECPGtrans(__LINE__, NULL, "commit work");}
00131 #line 31 "code100.pgc"
00132
00133 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00134
00135 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update test set payload = payload + 1 where index = - 1", ECPGt_EOIT, ECPGt_EORT);}
00136 #line 35 "code100.pgc"
00137
00138 if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00139
00140 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from test where index = - 1", ECPGt_EOIT, ECPGt_EORT);}
00141 #line 38 "code100.pgc"
00142
00143 if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00144
00145 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( select * from test where index = - 1 )", ECPGt_EOIT, ECPGt_EORT);}
00146 #line 41 "code100.pgc"
00147
00148 if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00149
00150 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);}
00151 #line 44 "code100.pgc"
00152
00153 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00154 { ECPGtrans(__LINE__, NULL, "commit work");}
00155 #line 46 "code100.pgc"
00156
00157 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00158
00159 { ECPGdisconnect(__LINE__, "CURRENT");}
00160 #line 49 "code100.pgc"
00161
00162 if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
00163 return 0;
00164 }