9 using namespace oracle::occi;
32 throw(std::runtime_error)
34 this->checkConnection();
37 m_writeStmt = m_conn->createStatement();
38 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" (fgr_conf_id, logic_id, "
39 "threshold, lut_fg ) "
40 "VALUES (:fgr_conf_id, :logic_id, "
41 ":threshold, :lut_fg )" );
43 throw(std::runtime_error(
"FEConfigFgrEEStripDat::prepareWrite(): "+e.getMessage()));
50 throw(std::runtime_error)
52 this->checkConnection();
55 int iconfID = iconf->fetchID();
56 if (!iconfID) {
throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeDB: ICONF not in DB")); }
58 int logicID = ecid->getLogicID();
59 if (!logicID) {
throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeDB: Bad EcalLogicID")); }
62 m_writeStmt->setInt(1, iconfID);
63 m_writeStmt->setInt(2, logicID);
64 m_writeStmt->setUInt(3, item->getThreshold());
65 m_writeStmt->setUInt(4, item->getLutFg());
67 m_writeStmt->executeUpdate();
69 throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeDB(): "+e.getMessage()));
76 throw(std::runtime_error)
78 this->checkConnection();
81 iconf->setConnection(m_env, m_conn);
82 int iconfID = iconf->fetchID();
90 m_readStmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
91 "d.threshold, d.lut_fg "
92 "FROM channelview cv JOIN "+getTable()+
" d "
93 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
94 "WHERE fgr_conf_id = :fgr_conf_id");
95 m_readStmt->setInt(1, iconfID);
96 ResultSet* rset = m_readStmt->executeQuery();
98 std::pair< EcalLogicID, FEConfigFgrEEStripDat >
p;
100 while(rset->next()) {
115 throw(std::runtime_error(
"FEConfigFgrEEStripDat::fetchData: "+e.getMessage()));
120 throw(std::runtime_error)
122 this->checkConnection();
123 this->checkPrepare();
125 int iconfID = iconf->fetchID();
126 if (!iconfID) {
throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeArrayDB: ICONF not in DB")); }
129 int nrows=
data->size();
130 int* ids=
new int[nrows];
131 int* iconfid_vec=
new int[nrows];
132 unsigned int* xx=
new unsigned int[nrows];
133 unsigned int* yy=
new unsigned int[nrows];
136 ub2* ids_len=
new ub2[nrows];
137 ub2* iconf_len=
new ub2[nrows];
138 ub2* x_len=
new ub2[nrows];
139 ub2* y_len=
new ub2[nrows];
145 typedef map< EcalLogicID, FEConfigFgrEEStripDat >::const_iterator CI;
146 for (CI
p =
data->begin();
p !=
data->end(); ++
p) {
147 channel = &(
p->first);
149 if (!logicID) {
throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeArrayDB: Bad EcalLogicID")); }
151 iconfid_vec[
count]=iconfID;
153 dataitem = &(
p->second);
173 m_writeStmt->setDataBuffer(1, (dvoid*)iconfid_vec, OCCIINT,
sizeof(iconfid_vec[0]),iconf_len);
174 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT,
sizeof(ids[0]), ids_len );
175 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIUNSIGNED_INT ,
sizeof(xx[0]), x_len );
176 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIUNSIGNED_INT ,
sizeof(yy[0]), y_len );
178 m_writeStmt->executeArrayUpdate(nrows);
181 delete [] iconfid_vec;
191 throw(std::runtime_error(
"FEConfigFgrEEStripDat::writeArrayDB(): "+e.getMessage()));
unsigned int getThreshold() const
oracle::occi::SQLException SQLException
void setThreshold(unsigned int mean)
void writeArrayDB(const std::map< EcalLogicID, FEConfigFgrEEStripDat > *data, FEConfigFgrInfo *iconf)
void fetchData(std::map< EcalLogicID, FEConfigFgrEEStripDat > *fillMap, FEConfigFgrInfo *iconf)
void setLutFg(unsigned int mean)
unsigned int getLutFg() const
oracle::occi::ResultSet ResultSet
void writeDB(const EcalLogicID *ecid, const FEConfigFgrEEStripDat *item, FEConfigFgrInfo *iconf)