4 #include <boost/lexical_cast.hpp> 16 m_writeStmt =
nullptr;
31 this->checkConnection();
34 m_writeStmt = m_conn->createStatement();
36 m_writeStmt->setSQL(
"INSERT INTO run_crystal_errors_dat (iov_id, logic_id, " 38 "VALUES (:iov_id, :logic_id, " 39 "to_number(:error_bits))");
40 }
catch (SQLException &
e) {
41 throw(std::runtime_error(
"RunCrystalErrorsDat::prepareWrite(): "+e.getMessage()));
50 this->checkConnection();
53 int iovID = iov->fetchID();
54 if (!iovID) {
throw(std::runtime_error(
"RunCrystalErrorsDat::writeDB: IOV not in DB")); }
56 int logicID = ecid->getLogicID();
57 if (!logicID) {
throw(std::runtime_error(
"RunCrystalErrorsDat::writeDB: Bad EcalLogicID")); }
60 m_writeStmt->setInt(1, iovID);
61 m_writeStmt->setInt(2, logicID);
62 m_writeStmt->setString(3, std::to_string(item->getErrorBits()));
63 m_writeStmt->executeUpdate();
64 }
catch (SQLException &
e) {
65 throw(std::runtime_error(
"RunCrystalErrorsDat::writeDB(): "+e.getMessage()));
74 this->checkConnection();
77 iov->setConnection(m_env, m_conn);
78 int iovID = iov->fetchID();
85 Statement* stmt = m_conn->createStatement();
87 stmt->setSQL(
"SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 88 "to_char(d.error_bits) " 89 "FROM channelview cv JOIN run_crystal_errors_dat d " 90 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 91 "WHERE d.iov_id = :iov_id");
92 stmt->setInt(1, iovID);
93 ResultSet* rset = stmt->executeQuery();
95 std::pair< EcalLogicID, RunCrystalErrorsDat >
p;
105 dat.
setErrorBits( boost::lexical_cast<uint64_t>(rset->getString(7)) );
110 m_conn->terminateStatement(stmt);
112 }
catch (SQLException &
e) {
113 throw(std::runtime_error(
"RunCrystalErrorsDat::fetchData(): "+e.getMessage()));
~RunCrystalErrorsDat() override
void fetchData(std::map< EcalLogicID, RunCrystalErrorsDat > *fillMap, RunIOV *iov) noexcept(false)
void prepareWrite() noexcept(false) override
void setErrorBits(uint64_t bits)
void writeDB(const EcalLogicID *ecid, const RunCrystalErrorsDat *item, RunIOV *iov) noexcept(false)