47 this->checkConnection();
50 m_writeStmt = m_conn->createStatement();
51 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" (rec_id, sm_id, fed_id, tt_id, cry_id, wei0, wei1, wei2, wei3, wei4, wei5 ) " 52 "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10, :11 )");
54 throw(std::runtime_error(
"ODWeightsDat::prepareWrite(): "+e.getMessage()));
63 this->checkConnection();
66 m_writeStmt->setInt(1, item->getId());
67 m_writeStmt->setInt(2, item->getSMId());
68 m_writeStmt->setInt(3, item->getFedId() );
69 m_writeStmt->setInt(4, item->getTTId() );
70 m_writeStmt->setInt(5, item->getCrystalId() );
72 m_writeStmt->setFloat(6, item->getWeight0() );
73 m_writeStmt->setFloat(7, item->getWeight1() );
74 m_writeStmt->setFloat(8, item->getWeight2() );
75 m_writeStmt->setFloat(9, item->getWeight3() );
76 m_writeStmt->setFloat(10, item->getWeight4() );
77 m_writeStmt->setFloat(11, item->getWeight5() );
79 m_writeStmt->executeUpdate();
81 throw(std::runtime_error(
"ODWeightsDat::writeDB(): "+e.getMessage()));
90 this->checkConnection();
92 iov->setConnection(m_env, m_conn);
93 int iovID = iov->fetchID();
100 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" WHERE rec_id = :rec_id order by sm_id, fed_id, tt_id, cry_id");
101 m_readStmt->setInt(1, iovID);
102 ResultSet* rset = m_readStmt->executeQuery();
106 while(rset->next()) {
108 dat.
setSMId( rset->getInt(2) );
110 dat.
setTTId( rset->getInt(4) );
121 for(
int iwei = 0; iwei < 6; iwei++) {
122 dat.
setWeight(iwei, rset->getFloat(6 + iwei) );
124 std::vector<float> dccwei( m_wei, m_wei+6);
125 dccw.push_back(dccwei);
131 throw(std::runtime_error(
"ODWeightsDat::fetchData(): "+e.getMessage()));
138 this->checkConnection();
141 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" WHERE rec_id = :1 order by sm_id, fed_id, tt_id, cry_id");
142 m_readStmt->setInt(1,
p->getId());
143 ResultSet* rset = m_readStmt->executeQuery();
146 while(rset->next()) {
148 p->setSMId( rset->getInt(2) );
149 p->setFedId( rset->getInt(3) );
150 p->setTTId( rset->getInt(4) );
151 p->setCrystalId( rset->getInt(5) );
152 for(
int iwei = 0; iwei < 6; iwei++) {
153 p->setWeight(iwei, rset->getFloat(6 + iwei) );
155 std::vector<float> dccwei( m_wei, m_wei+6);
156 dccw.push_back(dccwei);
158 std::cout <<
" table " << getTable() <<
" total nb of rows " << row << std::endl;
161 throw(std::runtime_error(
"ODWeightsDat::fetchData(): "+e.getMessage()));
170 this->checkConnection();
172 int iovID = iov->fetchID();
173 if (!iovID) {
throw(std::runtime_error(
"ODDelays::writeArrayDB: ODFEDelaysInfo not in DB")); }
176 int nrows=
data.size();
177 int* ids=
new int[nrows];
178 int*
xx=
new int[nrows];
179 int*
yy=
new int[nrows];
180 int*
zz=
new int[nrows];
181 int* st=
new int[nrows];
182 float* xx1=
new float[nrows];
183 float* yy1=
new float[nrows];
184 float* zz1=
new float[nrows];
185 float* xx2=
new float[nrows];
186 float* yy2=
new float[nrows];
187 float* zz2=
new float[nrows];
190 ub2* ids_len=
new ub2[nrows];
191 ub2* x_len=
new ub2[nrows];
192 ub2* y_len=
new ub2[nrows];
193 ub2* z_len=
new ub2[nrows];
194 ub2* st_len=
new ub2[nrows];
195 ub2* x1_len=
new ub2[nrows];
196 ub2* y1_len=
new ub2[nrows];
197 ub2* z1_len=
new ub2[nrows];
198 ub2* x2_len=
new ub2[nrows];
199 ub2* y2_len=
new ub2[nrows];
200 ub2* z2_len=
new ub2[nrows];
236 m_writeStmt->setDataBuffer(1, (dvoid*)ids, OCCIINT,
sizeof(ids[0]),ids_len);
237 m_writeStmt->setDataBuffer(2, (dvoid*)xx, OCCIINT ,
sizeof(xx[0]), x_len );
238 m_writeStmt->setDataBuffer(3, (dvoid*)yy, OCCIINT ,
sizeof(yy[0]), y_len );
239 m_writeStmt->setDataBuffer(4, (dvoid*)zz, OCCIINT ,
sizeof(zz[0]), z_len );
240 m_writeStmt->setDataBuffer(5, (dvoid*)st, OCCIINT ,
sizeof(st[0]), st_len );
241 m_writeStmt->setDataBuffer(6, (dvoid*)xx1, OCCIFLOAT ,
sizeof(xx1[0]), x1_len );
242 m_writeStmt->setDataBuffer(7, (dvoid*)yy1, OCCIFLOAT ,
sizeof(yy1[0]), y1_len );
243 m_writeStmt->setDataBuffer(8, (dvoid*)zz1, OCCIFLOAT ,
sizeof(zz1[0]), z1_len );
244 m_writeStmt->setDataBuffer(9, (dvoid*)xx2, OCCIFLOAT ,
sizeof(xx2[0]), x2_len );
245 m_writeStmt->setDataBuffer(10, (dvoid*)yy2, OCCIFLOAT ,
sizeof(yy2[0]), y2_len );
246 m_writeStmt->setDataBuffer(11, (dvoid*)zz2, OCCIFLOAT ,
sizeof(zz2[0]), z2_len );
249 m_writeStmt->executeArrayUpdate(nrows);
276 throw(std::runtime_error(
"ODWeightsDat::writeArrayDB(): "+e.getMessage()));
void setWeight(int pos, float x)
void prepareWrite() noexcept(false)
void writeArrayDB(const std::vector< ODWeightsDat > &data, ODFEWeightsInfo *iov) noexcept(false)
void setCrystalId(int dac)
oracle::occi::ResultSet ResultSet
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)