13 m_writeStmt =
nullptr;
38 this->checkConnection();
41 m_writeStmt = m_conn->createStatement();
42 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
43 " (rec_id, sm_id, fed_id, tt_id, cry_id, wei0, wei1, wei2, wei3, wei4, wei5 ) " 44 "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10, :11 )");
46 throw(std::runtime_error(
"ODWeightsDat::prepareWrite(): " + e.getMessage()));
51 this->checkConnection();
54 m_writeStmt->setInt(1,
item->getId());
55 m_writeStmt->setInt(2,
item->getSMId());
56 m_writeStmt->setInt(3,
item->getFedId());
57 m_writeStmt->setInt(4,
item->getTTId());
58 m_writeStmt->setInt(5,
item->getCrystalId());
60 m_writeStmt->setFloat(6,
item->getWeight0());
61 m_writeStmt->setFloat(7,
item->getWeight1());
62 m_writeStmt->setFloat(8,
item->getWeight2());
63 m_writeStmt->setFloat(9,
item->getWeight3());
64 m_writeStmt->setFloat(10,
item->getWeight4());
65 m_writeStmt->setFloat(11,
item->getWeight5());
67 m_writeStmt->executeUpdate();
69 throw(std::runtime_error(
"ODWeightsDat::writeDB(): " + e.getMessage()));
74 this->checkConnection();
76 iov->setConnection(m_env, m_conn);
77 int iovID = iov->fetchID();
84 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id, cry_id");
85 m_readStmt->setInt(1, iovID);
86 ResultSet* rset = m_readStmt->executeQuery();
90 while (rset->next()) {
105 for (
int iwei = 0; iwei < 6; iwei++) {
106 dat.
setWeight(iwei, rset->getFloat(6 + iwei));
108 std::vector<float> dccwei(m_wei, m_wei + 6);
109 dccw.push_back(dccwei);
113 throw(std::runtime_error(
"ODWeightsDat::fetchData(): " + e.getMessage()));
118 this->checkConnection();
121 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" WHERE rec_id = :1 order by sm_id, fed_id, tt_id, cry_id");
122 m_readStmt->setInt(1,
p->getId());
123 ResultSet* rset = m_readStmt->executeQuery();
126 while (rset->next()) {
128 p->setSMId(rset->getInt(2));
129 p->setFedId(rset->getInt(3));
130 p->setTTId(rset->getInt(4));
131 p->setCrystalId(rset->getInt(5));
132 for (
int iwei = 0; iwei < 6; iwei++) {
133 p->setWeight(iwei, rset->getFloat(6 + iwei));
135 std::vector<float> dccwei(m_wei, m_wei + 6);
136 dccw.push_back(dccwei);
138 std::cout <<
" table " << getTable() <<
" total nb of rows " << row << std::endl;
141 throw(std::runtime_error(
"ODWeightsDat::fetchData(): " + e.getMessage()));
148 this->checkConnection();
150 int iovID = iov->fetchID();
152 throw(std::runtime_error(
"ODDelays::writeArrayDB: ODFEDelaysInfo not in DB"));
155 int nrows =
data.size();
156 int*
ids =
new int[nrows];
157 int*
xx =
new int[nrows];
158 int*
yy =
new int[nrows];
159 int*
zz =
new int[nrows];
160 int* st =
new int[nrows];
161 float* xx1 =
new float[nrows];
162 float* yy1 =
new float[nrows];
163 float* zz1 =
new float[nrows];
164 float* xx2 =
new float[nrows];
165 float* yy2 =
new float[nrows];
166 float* zz2 =
new float[nrows];
168 ub2* ids_len =
new ub2[nrows];
169 ub2* x_len =
new ub2[nrows];
170 ub2* y_len =
new ub2[nrows];
171 ub2* z_len =
new ub2[nrows];
172 ub2* st_len =
new ub2[nrows];
173 ub2* x1_len =
new ub2[nrows];
174 ub2* y1_len =
new ub2[nrows];
175 ub2* z1_len =
new ub2[nrows];
176 ub2* x2_len =
new ub2[nrows];
177 ub2* y2_len =
new ub2[nrows];
178 ub2* z2_len =
new ub2[nrows];
211 m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
212 m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT,
sizeof(xx[0]), x_len);
213 m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT,
sizeof(yy[0]), y_len);
214 m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT,
sizeof(zz[0]), z_len);
215 m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT,
sizeof(st[0]), st_len);
216 m_writeStmt->setDataBuffer(6, (dvoid*)xx1, OCCIFLOAT,
sizeof(xx1[0]), x1_len);
217 m_writeStmt->setDataBuffer(7, (dvoid*)yy1, OCCIFLOAT,
sizeof(yy1[0]), y1_len);
218 m_writeStmt->setDataBuffer(8, (dvoid*)zz1, OCCIFLOAT,
sizeof(zz1[0]), z1_len);
219 m_writeStmt->setDataBuffer(9, (dvoid*)xx2, OCCIFLOAT,
sizeof(xx2[0]), x2_len);
220 m_writeStmt->setDataBuffer(10, (dvoid*)yy2, OCCIFLOAT,
sizeof(yy2[0]), y2_len);
221 m_writeStmt->setDataBuffer(11, (dvoid*)zz2, OCCIFLOAT,
sizeof(zz2[0]), z2_len);
223 m_writeStmt->executeArrayUpdate(nrows);
250 throw(std::runtime_error(
"ODWeightsDat::writeArrayDB(): " + e.getMessage()));
void setWeight(int pos, float x)
void writeArrayDB(const std::vector< ODWeightsDat > &data, ODFEWeightsInfo *iov) noexcept(false)
void setCrystalId(int dac)
void prepareWrite() noexcept(false) override
char data[epos_bytes_allocation]
oracle::occi::SQLException SQLException
void fetchData(std::vector< ODWeightsDat > *fillMap, ODFEWeightsInfo *iov) noexcept(false)
void writeDB(const ODWeightsDat *item, ODFEWeightsInfo *iov) noexcept(false)