14 m_writeStmt =
nullptr;
28 this->checkConnection();
31 m_writeStmt = m_conn->createStatement();
33 "INSERT INTO fe_config_lin_dat (lin_conf_id, logic_id, "
34 " multx12, multx6, multx1, shift12, shift6, shift1 ) "
35 "VALUES (:lin_conf_id, :logic_id, "
36 ":multx12, :multx6, :multx1, :shift12, :shift6, :shift1 )");
37 }
catch (SQLException&
e) {
38 throw(std::runtime_error(
"FEConfigLinDat::prepareWrite(): " +
e.getMessage()));
45 this->checkConnection();
48 int iconfID = iconf->fetchID();
50 throw(std::runtime_error(
"FEConfigLinDat::writeDB: ICONF not in DB"));
53 int logicID = ecid->getLogicID();
55 throw(std::runtime_error(
"FEConfigLinDat::writeDB: Bad EcalLogicID"));
59 m_writeStmt->setInt(1, iconfID);
60 m_writeStmt->setInt(2, logicID);
61 m_writeStmt->setInt(3,
item->getMultX12());
62 m_writeStmt->setInt(4,
item->getMultX6());
63 m_writeStmt->setInt(5,
item->getMultX1());
64 m_writeStmt->setInt(6,
item->getShift12());
65 m_writeStmt->setInt(7,
item->getShift6());
66 m_writeStmt->setInt(8,
item->getShift1());
68 m_writeStmt->executeUpdate();
69 }
catch (SQLException&
e) {
70 throw(std::runtime_error(
"FEConfigLinDat::writeDB(): " +
e.getMessage()));
75 this->checkConnection();
78 iconf->setConnection(m_env, m_conn);
79 int iconfID = iconf->fetchID();
87 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
88 "d.multx12, d.multx6, d.multx1, d.shift12, d.shift6, d.shift1 "
89 "FROM channelview cv JOIN fe_config_lin_dat d "
90 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
91 "WHERE lin_conf_id = :lin_conf_id");
92 m_readStmt->setInt(1, iconfID);
93 ResultSet* rset = m_readStmt->executeQuery();
95 std::pair<EcalLogicID, FEConfigLinDat>
p;
97 while (rset->next()) {
115 }
catch (SQLException&
e) {
116 throw(std::runtime_error(
"FEConfigLinDat::fetchData: " +
e.getMessage()));
122 this->checkConnection();
123 this->checkPrepare();
125 int iconfID = iconf->fetchID();
127 throw(std::runtime_error(
"FEConfigLinDat::writeArrayDB: ICONF not in DB"));
130 int nrows =
data->size();
131 int* ids =
new int[nrows];
132 int* iconfid_vec =
new int[nrows];
133 int*
xx =
new int[nrows];
134 int*
yy =
new int[nrows];
135 int*
zz =
new int[nrows];
136 int* ww =
new int[nrows];
137 int*
rr =
new int[nrows];
138 int*
ss =
new int[nrows];
140 ub2* ids_len =
new ub2[nrows];
141 ub2* iconf_len =
new ub2[nrows];
142 ub2* x_len =
new ub2[nrows];
143 ub2* y_len =
new ub2[nrows];
144 ub2* z_len =
new ub2[nrows];
145 ub2* w_len =
new ub2[nrows];
146 ub2* r_len =
new ub2[nrows];
147 ub2* s_len =
new ub2[nrows];
152 typedef map<EcalLogicID, FEConfigLinDat>::const_iterator CI;
153 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
154 channel = &(
p->first);
157 throw(std::runtime_error(
"FEConfigLinDat::writeArrayDB: Bad EcalLogicID"));
159 ids[
count] = logicID;
160 iconfid_vec[
count] = iconfID;
162 dataitem = &(
p->second);
179 iconf_len[
count] =
sizeof(iconfid_vec[
count]);
192 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT,
sizeof(iconfid_vec[0]), iconf_len);
193 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len);
194 m_writeStmt->setDataBuffer(3, (dvoid*)
xx, OCCIINT,
sizeof(
xx[0]), x_len);
195 m_writeStmt->setDataBuffer(4, (dvoid*)
yy, OCCIINT,
sizeof(
yy[0]), y_len);
196 m_writeStmt->setDataBuffer(5, (dvoid*)
zz, OCCIINT,
sizeof(
zz[0]), z_len);
197 m_writeStmt->setDataBuffer(6, (dvoid*)ww, OCCIINT,
sizeof(ww[0]), w_len);
198 m_writeStmt->setDataBuffer(7, (dvoid*)
rr, OCCIINT,
sizeof(
rr[0]), r_len);
199 m_writeStmt->setDataBuffer(8, (dvoid*)
ss, OCCIINT,
sizeof(
ss[0]), s_len);
201 m_writeStmt->executeArrayUpdate(nrows);
204 delete[] iconfid_vec;
221 }
catch (SQLException&
e) {
222 throw(std::runtime_error(
"FEConfigLinDat::writeArrayDB(): " +
e.getMessage()));