15 m_writeStmt =
nullptr;
33 this->checkConnection();
36 m_writeStmt = m_conn->createStatement();
37 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" (spi_conf_id, logic_id, " 39 "VALUES (:spi_conf_id, :logic_id, " 40 ":spike_threshold )" );
41 }
catch (SQLException &
e) {
42 throw(std::runtime_error(
"FEConfigSpikeDat::prepareWrite(): "+e.getMessage()));
50 this->checkConnection();
53 int iconfID = iconf->fetchID();
54 if (!iconfID) {
throw(std::runtime_error(
"FEConfigSpikeDat::writeDB: ICONF not in DB")); }
56 int logicID = ecid->getLogicID();
57 if (!logicID) {
throw(std::runtime_error(
"FEConfigSpikeDat::writeDB: Bad EcalLogicID")); }
60 m_writeStmt->setInt(1, iconfID);
61 m_writeStmt->setInt(2, logicID);
62 m_writeStmt->setInt(3, item->getSpikeThreshold());
64 m_writeStmt->executeUpdate();
65 }
catch (SQLException &
e) {
66 throw(std::runtime_error(
"FEConfigSpikeDat::writeDB(): "+e.getMessage()));
75 this->checkConnection();
78 iconf->setConnection(m_env, m_conn);
79 int iconfID = iconf->fetchID();
87 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 88 "d.spike_threshold FROM channelview cv JOIN "+getTable()+
" d ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 89 "WHERE spi_conf_id = :spi_conf_id");
90 m_readStmt->setInt(1, iconfID);
91 ResultSet* rset = m_readStmt->executeQuery();
93 std::pair< EcalLogicID, FEConfigSpikeDat >
p;
108 }
catch (SQLException &
e) {
109 throw(std::runtime_error(
"FEConfigSpikeDat::fetchData: "+e.getMessage()));
116 this->checkConnection();
117 this->checkPrepare();
119 int iconfID = iconf->fetchID();
120 if (!iconfID) {
throw(std::runtime_error(
"FEConfigSpikeDat::writeArrayDB: ICONF not in DB")); }
123 int nrows=
data->size();
124 int* ids=
new int[nrows];
125 int* iconfid_vec=
new int[nrows];
126 int*
xx=
new int[nrows];
128 ub2* ids_len=
new ub2[nrows];
129 ub2* iconf_len=
new ub2[nrows];
130 ub2* x_len=
new ub2[nrows];
136 typedef map< EcalLogicID, FEConfigSpikeDat >::const_iterator CI;
137 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
138 channel = &(
p->first);
140 if (!logicID) {
throw(std::runtime_error(
"FEConfigSpikeDat::writeArrayDB: Bad EcalLogicID")); }
142 iconfid_vec[
count]=iconfID;
144 dataitem = &(
p->second);
160 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT,
sizeof(iconfid_vec[0]),iconf_len);
161 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
162 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIINT ,
sizeof(xx[0]), x_len );
164 m_writeStmt->executeArrayUpdate(nrows);
167 delete [] iconfid_vec;
174 }
catch (SQLException &
e) {
175 throw(std::runtime_error(
"FEConfigSpikeDat::writeArrayDB(): "+e.getMessage()));
void prepareWrite() noexcept(false) override
void setSpikeThreshold(int x)
void writeDB(const EcalLogicID *ecid, const FEConfigSpikeDat *item, FEConfigSpikeInfo *iconf) noexcept(false)
void fetchData(std::map< EcalLogicID, FEConfigSpikeDat > *fillMap, FEConfigSpikeInfo *iconf) noexcept(false)
~FEConfigSpikeDat() override
char data[epos_bytes_allocation]
void writeArrayDB(const std::map< EcalLogicID, FEConfigSpikeDat > *data, FEConfigSpikeInfo *iconf) noexcept(false)
int getSpikeThreshold() const