15 m_writeStmt =
nullptr;
25 this->checkConnection();
28 m_writeStmt = m_conn->createStatement();
30 "INSERT INTO cali_gain_ratio_dat (iov_id, logic_id, " 31 "g1_g6, g6_g12, task_status) " 32 "VALUES (:iov_id, :logic_id, " 34 }
catch (SQLException&
e) {
35 throw(std::runtime_error(
"CaliGainRatioDat::prepareWrite(): " +
e.getMessage()));
40 this->checkConnection();
43 int iovID = iov->fetchID();
45 throw(std::runtime_error(
"CaliGainRatioDat::writeDB: IOV not in DB"));
48 int logicID = ecid->getLogicID();
50 throw(std::runtime_error(
"CaliGainRatioDat::writeDB: Bad EcalLogicID"));
54 m_writeStmt->setInt(1, iovID);
55 m_writeStmt->setInt(2, logicID);
57 m_writeStmt->setFloat(3,
item->getG1G12());
58 m_writeStmt->setFloat(4,
item->getG6G12());
59 m_writeStmt->setInt(5,
item->getTaskStatus());
61 m_writeStmt->executeUpdate();
62 }
catch (SQLException&
e) {
63 throw(std::runtime_error(
"CaliGainRatioDat::writeDB(): " +
e.getMessage()));
68 this->checkConnection();
71 iov->setConnection(m_env, m_conn);
72 int iovID = iov->fetchID();
80 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 81 "d.g1_g6, d.g6_g12, d.task_status " 82 "FROM channelview cv JOIN cali_gain_ratio_dat d " 83 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 84 "WHERE d.iov_id = :iov_id");
85 m_readStmt->setInt(1, iovID);
86 ResultSet* rset = m_readStmt->executeQuery();
88 std::pair<EcalLogicID, CaliGainRatioDat>
p;
90 while (rset->next()) {
105 }
catch (SQLException&
e) {
106 throw(std::runtime_error(
"CaliGainRatioDat::fetchData(): " +
e.getMessage()));
111 this->checkConnection();
112 this->checkPrepare();
114 int iovID = iov->fetchID();
116 throw(std::runtime_error(
"CaliGainRatioDat::writeArrayDB: IOV not in DB"));
119 int nrows =
data->size();
120 int* ids =
new int[nrows];
121 int* iovid_vec =
new int[nrows];
122 float*
xx =
new float[nrows];
123 float*
yy =
new float[nrows];
124 int* st =
new int[nrows];
126 ub2* ids_len =
new ub2[nrows];
127 ub2* iov_len =
new ub2[nrows];
128 ub2* x_len =
new ub2[nrows];
129 ub2* y_len =
new ub2[nrows];
130 ub2* st_len =
new ub2[nrows];
135 typedef map<EcalLogicID, CaliGainRatioDat>::const_iterator CI;
136 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
137 channel = &(
p->first);
140 throw(std::runtime_error(
"CaliGainRatioDat::writeArrayDB: Bad EcalLogicID"));
142 ids[
count] = logicID;
143 iovid_vec[
count] = iovID;
145 dataitem = &(
p->second);
166 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT,
sizeof(iovid_vec[0]), iov_len);
167 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
168 m_writeStmt->setDataBuffer(3, (dvoid*)
xx, OCCIFLOAT,
sizeof(
xx[0]), x_len);
169 m_writeStmt->setDataBuffer(4, (dvoid*)
yy, OCCIFLOAT,
sizeof(
yy[0]), y_len);
170 m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
172 m_writeStmt->executeArrayUpdate(nrows);
186 }
catch (SQLException&
e) {
187 throw(std::runtime_error(
"CaliGainRatio::writeArrayDB(): " +
e.getMessage()));
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)
void writeDB(const EcalLogicID *ecid, const CaliGainRatioDat *item, CaliIOV *iov) noexcept(false)
char data[epos_bytes_allocation]
bool getTaskStatus() const
~CaliGainRatioDat() override