00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef STATEMENT_H
00021 #define STATEMENT_H
00022 #include "Parser.h"
00023
00024 class Statement
00025 {
00026 protected:
00027 ParsedData *parsedData;
00028 DatabaseManager *dbMgr;
00029
00030 public:
00031 void setParsedData(ParsedData *pData) { parsedData = pData; }
00032 void setDbMgr(DatabaseManager *dbmgr) { dbMgr = dbmgr; }
00033
00034
00035 virtual DbRetVal execute(int &rowsAffected)=0;
00036 virtual DbRetVal setParam(int paramNo, void *value)=0;
00037
00038 virtual DbRetVal setShortParam(int paramNo, short value)=0;
00039 virtual DbRetVal setIntParam(int paramNo, int value)=0;
00040 virtual DbRetVal setLongParam(int paramNo, long value)=0;
00041 virtual DbRetVal setLongLongParam(int paramNo, long long value)=0;
00042 virtual DbRetVal setByteIntParam(int paramNo, ByteInt value)=0;
00043 virtual DbRetVal setFloatParam(int paramNo, float value)=0;
00044 virtual DbRetVal setDoubleParam(int paramNo, double value)=0;
00045 virtual DbRetVal setStringParam(int paramNo, char *value)=0;
00046 virtual DbRetVal setDateParam(int paramNo, Date value)=0;
00047 virtual DbRetVal setTimeParam(int paramNo, Time value)=0;
00048 virtual DbRetVal setTimeStampParam(int paramNo, TimeStamp value)=0;
00049
00050
00051 virtual DbRetVal resolve()=0;
00052 virtual ~Statement(){}
00053 };
00054
00055 class DmlStatement : public Statement
00056 {
00057 protected:
00058 Table *table;
00059
00060 void **params;
00061
00062
00063 char **paramValues;
00064 int totalParams;
00065
00066 public:
00067 int noOfParamFields() { return totalParams; }
00068 virtual DbRetVal getParamFldInfo(int paramPos, FieldInfo *&info) =0;
00069
00070 virtual DbRetVal execute(int &rowsAffected)=0;
00071 virtual DbRetVal setParam(int paramNo, void *value)=0;
00072
00073 virtual DbRetVal setShortParam(int paramNo, short value)=0;
00074 virtual DbRetVal setIntParam(int paramNo, int value)=0;
00075 virtual DbRetVal setLongParam(int paramNo, long value)=0;
00076 virtual DbRetVal setLongLongParam(int paramNo, long long value)=0;
00077 virtual DbRetVal setByteIntParam(int paramNo, ByteInt value)=0;
00078 virtual DbRetVal setFloatParam(int paramNo, float value)=0;
00079 virtual DbRetVal setDoubleParam(int paramNo, double value)=0;
00080 virtual DbRetVal setStringParam(int paramNo, char *value)=0;
00081 virtual DbRetVal setDateParam(int paramNo, Date value)=0;
00082 virtual DbRetVal setTimeParam(int paramNo, Time value)=0;
00083 virtual DbRetVal setTimeStampParam(int paramNo, TimeStamp value)=0;
00084
00085
00086 virtual DbRetVal resolve()=0;
00087 virtual ~DmlStatement(){}
00088 };
00089
00090 class InsStatement : public DmlStatement
00091 {
00092 public:
00093 DbRetVal getParamFldInfo(int paramPos, FieldInfo *&info);
00094
00095 DbRetVal execute(int &rowsAffected);
00096 DbRetVal setParam(int paramNo, void *value);
00097
00098 DbRetVal setShortParam(int paramNo, short value);
00099 DbRetVal setIntParam(int paramNo, int value);
00100 DbRetVal setLongParam(int paramNo, long value);
00101 DbRetVal setLongLongParam(int paramNo, long long value);
00102 DbRetVal setByteIntParam(int paramNo, ByteInt value);
00103 DbRetVal setFloatParam(int paramNo, float value);
00104 DbRetVal setDoubleParam(int paramNo, double value);
00105 DbRetVal setStringParam(int paramNo, char *value);
00106 DbRetVal setDateParam(int paramNo, Date value);
00107 DbRetVal setTimeParam(int paramNo, Time value);
00108 DbRetVal setTimeStampParam(int paramNo, TimeStamp value);
00109
00110 DbRetVal resolve();
00111 InsStatement();
00112 ~InsStatement();
00113 };
00114
00115 class SelStatement : public DmlStatement
00116 {
00117 private:
00118 DbRetVal resolveStar();
00119 DbRetVal setBindFieldAndValues();
00120 DbRetVal resolveForCondition();
00121
00122 public:
00123 FieldValue **bindFields;
00124 char **bindFieldValues;
00125 int totalFields;
00126
00127
00128 DbRetVal execute(int &rowsAffected);
00129 DbRetVal setParam(int paramNo, void *value);
00130
00131 DbRetVal setShortParam(int paramNo, short value);
00132 DbRetVal setIntParam(int paramNo, int value);
00133 DbRetVal setLongParam(int paramNo, long value);
00134 DbRetVal setLongLongParam(int paramNo, long long value);
00135 DbRetVal setByteIntParam(int paramNo, ByteInt value);
00136 DbRetVal setFloatParam(int paramNo, float value);
00137 DbRetVal setDoubleParam(int paramNo, double value);
00138 DbRetVal setStringParam(int paramNo, char *value);
00139 DbRetVal setDateParam(int paramNo, Date value);
00140 DbRetVal setTimeParam(int paramNo, Time value);
00141 DbRetVal setTimeStampParam(int paramNo, TimeStamp value);
00142
00143 DbRetVal close();
00144 DbRetVal resolve();
00145 SelStatement();
00146 ~SelStatement();
00147
00148
00149 DbRetVal setBindField(int pos, void* value);
00150
00151 int noOfProjFields();
00152 DbRetVal getProjFldInfo (int projpos, FieldInfo *&fInfo);
00153 DbRetVal getParamFldInfo(int paramPos, FieldInfo *&info);
00154
00155 void *fetch();
00156 void *fetch(DbRetVal &rv);
00157 void *fetchAndPrint(bool SQL);
00158 void *next();
00159 void *getFieldValuePtr( int );
00160 };
00161
00162 class UpdStatement : public DmlStatement
00163 {
00164 public:
00165 DbRetVal execute(int &rowsAffected);
00166 DbRetVal setParam(int paramNo, void *value);
00167
00168 DbRetVal setShortParam(int paramNo, short value);
00169 DbRetVal setIntParam(int paramNo, int value);
00170 DbRetVal setLongParam(int paramNo, long value);
00171 DbRetVal setLongLongParam(int paramNo, long long value);
00172 DbRetVal setByteIntParam(int paramNo, ByteInt value);
00173 DbRetVal setFloatParam(int paramNo, float value);
00174 DbRetVal setDoubleParam(int paramNo, double value);
00175 DbRetVal setStringParam(int paramNo, char *value);
00176 DbRetVal setDateParam(int paramNo, Date value);
00177 DbRetVal setTimeParam(int paramNo, Time value);
00178 DbRetVal setTimeStampParam(int paramNo, TimeStamp value);
00179
00180 DbRetVal getParamFldInfo(int paramPos, FieldInfo *&info);
00181
00182
00183 DbRetVal resolve();
00184 UpdStatement();
00185 ~UpdStatement();
00186
00187 int totalAssignParams;
00188 DbRetVal resolveForAssignment();
00189 };
00190
00191 class DelStatement : public DmlStatement
00192 {
00193 public:
00194 DbRetVal execute(int &rowsAffected);
00195 DbRetVal setParam(int paramNo, void *value);
00196
00197 DbRetVal setShortParam(int paramNo, short value);
00198 DbRetVal setIntParam(int paramNo, int value);
00199 DbRetVal setLongParam(int paramNo, long value);
00200 DbRetVal setLongLongParam(int paramNo, long long value);
00201 DbRetVal setByteIntParam(int paramNo, ByteInt value);
00202 DbRetVal setFloatParam(int paramNo, float value);
00203 DbRetVal setDoubleParam(int paramNo, double value);
00204 DbRetVal setStringParam(int paramNo, char *value);
00205 DbRetVal setDateParam(int paramNo, Date value);
00206 DbRetVal setTimeParam(int paramNo, Time value);
00207 DbRetVal setTimeStampParam(int paramNo, TimeStamp value);
00208
00209 DbRetVal getParamFldInfo(int paramPos, FieldInfo *&info);
00210
00211 DbRetVal resolve();
00212 DelStatement();
00213 ~DelStatement();
00214
00215 DbRetVal resolveForCondition();
00216
00217 };
00218
00219 class DdlStatement : public Statement
00220 {
00221 public:
00222 DbRetVal execute(int &rowsAffected)=0;
00223
00224 DbRetVal resolve()=0;
00225
00226 DbRetVal setParam(int paramNo, void *value) { }
00227 DbRetVal setShortParam(int paramNo, short value) { }
00228 DbRetVal setIntParam(int paramNo, int value) { }
00229 DbRetVal setLongParam(int paramNo, long value) { }
00230 DbRetVal setLongLongParam(int paramNo, long long value) { }
00231 DbRetVal setByteIntParam(int paramNo, ByteInt value) { }
00232 DbRetVal setFloatParam(int paramNo, float value) { }
00233 DbRetVal setDoubleParam(int paramNo, double value) { }
00234 DbRetVal setStringParam(int paramNo, char *value) { }
00235 DbRetVal setDateParam(int paramNo, Date value) { }
00236 DbRetVal setTimeParam(int paramNo, Time value) { }
00237 DbRetVal setTimeStampParam(int paramNo, TimeStamp value) { }
00238 };
00239
00240 class CreateTblStatement : public DdlStatement
00241 {
00242 public:
00243 DbRetVal execute(int &rowsAffected);
00244 DbRetVal resolve();
00245
00246 CreateTblStatement();
00247 ~CreateTblStatement();
00248
00249 private:
00250 char tblName[IDENTIFIER_LENGTH];
00251 TableDef tblDef;
00252 };
00253
00254 class CreateIdxStatement : public DdlStatement
00255 {
00256 public:
00257 DbRetVal execute(int &rowsAffected);
00258 DbRetVal resolve(){return OK; }
00259
00260 CreateIdxStatement();
00261 ~CreateIdxStatement();
00262
00263 };
00264
00265 class DropTblStatement : public DdlStatement
00266 {
00267 public:
00268 DbRetVal execute(int &rowsAffected);
00269 DbRetVal resolve(){return OK; }
00270
00271 DropTblStatement(){}
00272 ~DropTblStatement(){}
00273 };
00274 class DropIdxStatement : public DdlStatement
00275 {
00276 public:
00277 DbRetVal execute(int &rowsAffected);
00278 DbRetVal resolve() {return OK; }
00279
00280 DropIdxStatement(){}
00281 ~DropIdxStatement(){}
00282 };
00283
00284 class StatementFactory
00285 {
00286 public:
00287 static Statement* getStatement(ParsedData *pData );
00288 };
00289 #endif