00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef zz_db_h
00010 #define zz_db_h
00011
00012 #include <zz_string.h>
00013 #include <zz_log.h>
00014 #include <zz_export.h>
00015 #include <otl.h>
00016
00017 #define BEGIN_TRY try{
00018 #define END_TRY }
00019
00020 #define BEGIN_CATCH catch (otl_exception& e){ CzzDbException::m_LastExtException = e;
00021 #define END_CATCH }
00022
00023
00024
00025
00026
00027 class ZZ_API CzzSQLStream: public otl_stream
00028 {
00029 private:
00030 CzzLog m_Log;
00031
00032 public:
00033 CzzSQLStream(otl_connect& db, const CzzString Stm, const short BufSize, int autocommit = 0);
00034
00035 int RowCount(void);
00036 char* GetSqlStm(void);
00037 otl_cursor* GetCurrentCursor(void);
00038 };
00039
00040
00041
00042
00043
00044 class ZZ_API CzzDb
00045 {
00046 static int m_cnt;
00047
00048 protected:
00049 otl_connect m_db;
00050 CzzString m_SQL;
00051
00052 CzzLog m_Log;
00053
00054 public:
00055 CzzDb(const CzzString& db_user, int autocommit = 1);
00056 ~CzzDb();
00057
00058 void Commit(void);
00059 void Rollback(void);
00060
00061 void GetSysDate(char* sysdate);
00062 void GetDbUser(char *dbUser);
00063
00064 CzzSQLStream* getStream( const CzzString& sql, const short bufsize );
00065
00066 int m_AutoCommit;
00067 };
00068
00069
00070 #endif