10 using namespace oracle::occi;
33 throw(std::runtime_error)
35 this->checkConnection();
38 m_writeStmt = m_conn->createStatement();
39 m_writeStmt->setSQL(
"INSERT INTO mon_pedestals_online_dat (iov_id, logic_id, "
40 "adc_mean_g12, adc_rms_g12, task_status) "
41 "VALUES (:iov_id, :logic_id, "
42 ":adc_mean_g12, :adc_rms_g12, :task_status)");
44 throw(std::runtime_error(
"MonPedestalsOnlineDat::prepareWrite(): "+e.getMessage()));
51 throw(std::runtime_error)
53 this->checkConnection();
56 int iovID =
iov->fetchID();
57 if (!iovID) {
throw(std::runtime_error(
"MonPedestalsOnlineDat::writeDB: IOV not in DB")); }
59 int logicID = ecid->getLogicID();
60 if (!logicID) {
throw(std::runtime_error(
"MonPedestalsOnlineDat::writeDB: Bad EcalLogicID")); }
63 m_writeStmt->setInt(1, iovID);
64 m_writeStmt->setInt(2, logicID);
65 m_writeStmt->setFloat(3, item->getADCMeanG12() );
66 m_writeStmt->setFloat(4, item->getADCRMSG12() );
67 m_writeStmt->setInt(5, item->getTaskStatus() );
69 m_writeStmt->executeUpdate();
71 throw(std::runtime_error(
"MonPedestalsOnlineDat::writeDB(): "+e.getMessage()));
78 throw(std::runtime_error)
80 this->checkConnection();
83 iov->setConnection(m_env, m_conn);
84 int iovID =
iov->fetchID();
92 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
93 "d.adc_mean_g12, d.adc_rms_g12, d.task_status "
94 "FROM channelview cv JOIN mon_pedestals_online_dat d "
95 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
96 "WHERE d.iov_id = :iov_id");
97 m_readStmt->setInt(1, iovID);
98 ResultSet* rset = m_readStmt->executeQuery();
100 std::pair< EcalLogicID, MonPedestalsOnlineDat >
p;
102 while(rset->next()) {
118 throw(std::runtime_error(
"MonPedestalsOnlineDat::fetchData(): "+e.getMessage()));
123 throw(std::runtime_error)
125 this->checkConnection();
126 this->checkPrepare();
128 int iovID =
iov->fetchID();
129 if (!iovID) {
throw(std::runtime_error(
"MonPedestalsOnlineDat::writeArrayDB: IOV not in DB")); }
132 int nrows=
data->size();
133 int* ids=
new int[nrows];
134 int* iovid_vec=
new int[nrows];
135 float* xx=
new float[nrows];
136 float* yy=
new float[nrows];
137 int* st=
new int[nrows];
139 ub2* ids_len=
new ub2[nrows];
140 ub2* iov_len=
new ub2[nrows];
141 ub2* x_len=
new ub2[nrows];
142 ub2* y_len=
new ub2[nrows];
143 ub2* st_len=
new ub2[nrows];
148 typedef map< EcalLogicID, MonPedestalsOnlineDat >::const_iterator CI;
149 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
150 channel = &(
p->first);
152 if (!logicID) {
throw(std::runtime_error(
"MonPedestalsOnlineDat::writeArrayDB: Bad EcalLogicID")); }
154 iovid_vec[
count]=iovID;
156 dataitem = &(
p->second);
181 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]),iov_len);
182 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
183 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT ,
sizeof(xx[0]), x_len );
184 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT ,
sizeof(yy[0]), y_len );
185 m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT ,
sizeof(st[0]), st_len );
188 m_writeStmt->executeArrayUpdate(nrows);
205 throw(std::runtime_error(
"MonPedestalsDat::writeArrayDB(): "+e.getMessage()));
oracle::occi::SQLException SQLException
void setTaskStatus(bool status)
void writeDB(const EcalLogicID *ecid, const MonPedestalsOnlineDat *item, MonRunIOV *iov)
void fetchData(std::map< EcalLogicID, MonPedestalsOnlineDat > *fillMap, MonRunIOV *iov)
void setADCMeanG12(float mean)
void writeArrayDB(const std::map< EcalLogicID, MonPedestalsOnlineDat > *data, MonRunIOV *iov)
bool getTaskStatus() const
float getADCMeanG12() const
oracle::occi::ResultSet ResultSet
void setADCRMSG12(float rms)
float getADCRMSG12() const