00001
00002
00003
00004
00005 #include "CTB.hxx"
00006 #include "CTBodbc.hxx"
00007 #include "CTBodbcConnect.hxx"
00008 #include "CTBodbcStatement.hxx"
00009 #include "CTBodbcTime.hxx"
00010
00011 #include "IDB.hxx"
00012 #include "IDBrunmap.hxx"
00013
00019
00021
00022 IDBrunmap::IDBrunmap()
00023 : m_idbc(IDBconnect::Default())
00024 {}
00025
00026
00028
00029 IDBrunmap::IDBrunmap(IDBconnect& idbc)
00030 : m_idbc(idbc)
00031 {}
00032
00033
00035
00036 IDBrunmap::~IDBrunmap()
00037 {}
00038
00039
00041
00046 int IDBrunmap::UrnFromHeadTime(const char* c_headtime)
00047 {
00048 CTBodbcStatement stmt(m_idbc.Dbc());
00049 CTBcstring<19> c_htime(c_headtime);
00050
00051 if (c_htime[0] == ' ') c_htime[0] = '0';
00052
00053 stmt.Prepare("SELECT urn FROM runmap WHERE headtime = ?");
00054 stmt.BindIParameter(1,SQL_CHAR,c_htime);
00055 stmt.Execute();
00056
00057 if (stmt.Fetch()) {
00058 int i_urn = -1;
00059 bool b_null;
00060 stmt.GetData(1,i_urn,b_null);
00061 return i_urn;
00062 }
00063
00064 return -1;
00065 }
00066
00067
00069
00075 const char* IDBrunmap::HeadTimeFromUrn(int i_urn)
00076 {
00077 CTBodbcStatement stmt(m_idbc.Dbc());
00078
00079 stmt.Prepare("SELECT headtime FROM runmap WHERE urn = ?");
00080 stmt.BindIParameter(1,SQL_INTEGER,i_urn);
00081 stmt.Execute();
00082
00083 if (stmt.Fetch()) {
00084 bool b_null;
00085 stmt.GetData(1,mc_headtime,mc_headtime.Size(),b_null);
00086 return mc_headtime;
00087 }
00088
00089 return "";
00090 }
00091
00092
00094
00099 int IDBrunmap::OrnFromUrn(int i_urn)
00100 {
00101 CTBodbcStatement stmt(m_idbc.Dbc());
00102
00103 stmt.Prepare("SELECT orn FROM runmap WHERE urn = ?");
00104 stmt.BindIParameter(1,SQL_INTEGER,i_urn);
00105 stmt.Execute();
00106
00107 if (stmt.Fetch()) {
00108 int i_orn = -1;
00109 bool b_null;
00110 stmt.GetData(1,i_orn,b_null);
00111 return i_orn;
00112 }
00113
00114 return -1;
00115 }
00116
00117
00119
00124 int IDBrunmap::TheadFromUrn(int i_urn)
00125 {
00126 CTBodbcStatement stmt(m_idbc.Dbc());
00127
00128 stmt.Prepare("SELECT thead FROM runmap WHERE urn = ?");
00129 stmt.BindIParameter(1,SQL_INTEGER,i_urn);
00130 stmt.Execute();
00131
00132 if (stmt.Fetch()) {
00133 CTBodbcTime time;
00134 bool b_null;
00135 stmt.GetData(1,time,b_null);
00136 return time.ToUTime();
00137 }
00138
00139 return -1;
00140 }
00141