00001
00007
00008
00009 #ifndef FBwUpdateH
00010 #define FBwUpdateH
00011 #include <ibase.h>
00012 #include <string>
00013 #include <FBwQuery.h>
00014
00015
00016
00018 namespace fbwrap
00019 {
00020
00021
00022 using std::string;
00023
00025 class FBwUpdate
00026 {
00027 string table;
00028 FBwBQuery *q;
00029 FBwBQuery updq;
00030 FBwBQuery insq;
00031 FBwBQuery delq;
00032 FBwBQuery refq;
00033 FBwDb *mdb;
00034 protected:
00035 void RefreshKey();
00036 void Execute();
00037 void Init();
00038
00039 struct {
00040 bool updCreated:1;
00041 bool insCreated:1;
00042 bool delCreated:1;
00043 bool refCreated:1;
00044 bool error:1;
00045 } stat;
00046 void ClearStat()
00047 {
00048 stat.updCreated=false;
00049 stat.insCreated=false;
00050 stat.delCreated=false;
00051 stat.refCreated=false;
00052 stat.error=false;
00053 }
00054 void CreateUpdate(const string &s);
00055 void CreateInsert(const string &s);
00056 void CreateDelete(const string &s);
00057 void CreateRefresh(const string &s);
00058
00059 FieldList *kp;
00060
00061 FieldList *dp;
00062 void RefreshValues();
00063 void RefreshKeys();
00064
00065 public:
00066 FBwUpdate(FBwDb *pMdb,const string &ptable):
00067 Values(pMdb),Keys(pMdb),insq(pMdb),delq(pMdb),updq(pMdb),refq(pMdb)
00068 {
00069 mdb=pMdb;
00070 table=ptable;
00071 ClearStat();
00072 kp=0;
00073 dp=0;
00074 Init();
00075 }
00076 FieldList Values;
00077 FieldList Keys;
00078 void Update();
00079 void Append();
00080 void Delete();
00081 void Refresh();
00082 void SetTable(const string &ptable)
00083 {
00084 table=ptable;
00085 Init();
00086 }
00087 const string &GetTable() const
00088 {
00089 return table;
00090 }
00091 void SetUpdateSql(const string &s);
00092 void SetInsertSql(const string &s);
00093 void SetDeleteSql(const string &s);
00094 void SetKeyLink(FieldList *fl)
00095 {
00096 kp=fl;
00097 }
00098 void SetDataLink(FieldList *fl)
00099 {
00100 dp=fl;
00101 }
00102 bool Error() const
00103 {
00104 return stat.error;
00105 }
00106 };
00107
00108 }
00109 #endif