00001
00002
00003
00004
00005 #ifndef dsCT_h
00006 #define dsCT_h
00007
00008 #include <ctpublic.h>
00009 #include <cspublic.h>
00010
00011 #include <dsSmartException.h>
00012 #include <dsSQLAccessor.h>
00013
00014 DECLARE_EXCEPTION2(dsCT, dsSQL);
00015
00016 #define CT_CS_VERSION CS_VERSION_100
00017
00021 class dsCT
00022 {
00023 CS_CONNECTION *_conn;
00024 CS_CONTEXT *_cntx;
00025 CS_RETCODE _ret;
00026
00027
00028 public :
00036 dsCT(CS_CHAR *servername, CS_CHAR *username = 0, CS_CHAR *password = 0);
00037 virtual ~dsCT();
00038
00046 virtual void Connect(CS_CHAR *servername, CS_CHAR *username, CS_CHAR *password);
00047
00051 virtual void Cleanup();
00052
00059 virtual void Execute(CS_COMMAND *cmd);
00060
00067 virtual CS_COMMAND *PrepareCall(CS_CHAR *query, CS_INT flags);
00068
00069 virtual CS_COMMAND *PrepareCall(CS_CHAR *query)
00070 { return PrepareCall(query, CS_RPC_CMD);
00071 }
00072
00078 virtual void ReleaseCall(CS_COMMAND *cmd);
00079
00086 int Fetch(CS_COMMAND *cmd, CS_INT nrows = 1);
00087
00088 virtual void BindParam(CS_COMMAND *cmd, CS_INT item, CS_INT ValueType, CS_VOID *value, CS_INT ValueSize);
00089
00090 virtual void BindParam(CS_COMMAND *cmd, CS_INT item, int* value)
00091 { BindParam(cmd, item, CS_INT_TYPE, (CS_VOID *) value, sizeof(CS_INT));
00092 }
00093
00094 virtual void BindParam(CS_COMMAND *cmd, CS_INT item, char *value, int size)
00095 { BindParam(cmd, item, CS_CHAR_TYPE, (CS_VOID *) value, size);
00096 }
00097
00098
00099 virtual void SetParam(CS_COMMAND *cmd, CS_CHAR *itemname, CS_INT ValueType, CS_VOID *itemvalue, CS_INT ValueSize);
00100
00101 virtual void SetParam(CS_COMMAND *cmd, CS_CHAR *ParamName, int value)
00102 { int valuep = value;
00103 SetParam(cmd, ParamName, CS_INT_TYPE, (CS_VOID *) &valuep, sizeof(valuep));
00104 }
00105
00106 virtual void SetParam(CS_COMMAND *cmd, CS_CHAR *ParamName, char *value, int size)
00107 { SetParam(cmd, ParamName, CS_CHAR_TYPE, (CS_VOID *) value, size);
00108 }
00109
00110
00111 protected:
00112 CS_RETCODE check_error(int line, CS_RETCODE status, char *desc);
00113
00114 };
00115
00116
00117
00118 #endif