16 m_writeStmt =
nullptr;
34 this->checkConnection();
37 m_writeStmt = m_conn->createStatement();
38 m_writeStmt->setSQL(
"INSERT INTO cali_gain_ratio_dat (iov_id, logic_id, " 39 "g1_g6, g6_g12, task_status) " 40 "VALUES (:iov_id, :logic_id, " 42 }
catch (SQLException &
e) {
43 throw(std::runtime_error(
std::string(
"CaliGainRatioDat::prepareWrite(): ")+getOraMessage(&e)));
52 this->checkConnection();
55 int iovID = iov->fetchID();
56 if (!iovID) {
throw(std::runtime_error(
"CaliGainRatioDat::writeDB: IOV not in DB")); }
58 int logicID = ecid->getLogicID();
59 if (!logicID) {
throw(std::runtime_error(
"CaliGainRatioDat::writeDB: Bad EcalLogicID")); }
62 m_writeStmt->setInt(1, iovID);
63 m_writeStmt->setInt(2, logicID);
65 m_writeStmt->setFloat(3, item->getG1G12() );
66 m_writeStmt->setFloat(4, item->getG6G12() );
67 m_writeStmt->setInt(5, item->getTaskStatus() );
69 m_writeStmt->executeUpdate();
70 }
catch (SQLException &
e) {
71 throw(std::runtime_error(
std::string(
"CaliGainRatioDat::writeDB(): ")+getOraMessage(&e)));
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.g1_g6, d.g6_g12, d.task_status " 94 "FROM channelview cv JOIN cali_gain_ratio_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, CaliGainRatioDat >
p;
102 while(rset->next()) {
108 getOraString(rset,6));
117 }
catch (SQLException &
e) {
118 throw(std::runtime_error(
std::string(
"CaliGainRatioDat::fetchData(): ")+getOraMessage(&e)));
125 this->checkConnection();
126 this->checkPrepare();
128 int iovID = iov->fetchID();
129 if (!iovID) {
throw(std::runtime_error(
"CaliGainRatioDat::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, CaliGainRatioDat >::const_iterator CI;
149 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
150 channel = &(
p->first);
152 if (!logicID) {
throw(std::runtime_error(
"CaliGainRatioDat::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);
204 }
catch (SQLException &
e) {
205 throw(std::runtime_error(
std::string(
"CaliGainRatio::writeArrayDB(): ")+getOraMessage(&e)));
void prepareWrite() noexcept(false) override
void setTaskStatus(bool s)
void writeArrayDB(const std::map< EcalLogicID, CaliGainRatioDat > *data, CaliIOV *iov) noexcept(false)
void fetchData(std::map< EcalLogicID, CaliGainRatioDat > *fillVec, CaliIOV *iov) noexcept(false)
bool getTaskStatus() const
void writeDB(const EcalLogicID *ecid, const CaliGainRatioDat *item, CaliIOV *iov) noexcept(false)
char data[epos_bytes_allocation]
~CaliGainRatioDat() override