4 #include <boost/lexical_cast.hpp>
15 m_writeStmt =
nullptr;
22 this->checkConnection();
25 m_writeStmt = m_conn->createStatement();
28 "INSERT INTO run_crystal_errors_dat (iov_id, logic_id, "
30 "VALUES (:iov_id, :logic_id, "
31 "to_number(:error_bits))");
32 }
catch (SQLException&
e) {
33 throw(std::runtime_error(
"RunCrystalErrorsDat::prepareWrite(): " +
e.getMessage()));
39 RunIOV* iov) noexcept(
false) {
40 this->checkConnection();
43 int iovID = iov->fetchID();
45 throw(std::runtime_error(
"RunCrystalErrorsDat::writeDB: IOV not in DB"));
48 int logicID = ecid->getLogicID();
50 throw(std::runtime_error(
"RunCrystalErrorsDat::writeDB: Bad EcalLogicID"));
54 m_writeStmt->setInt(1, iovID);
55 m_writeStmt->setInt(2, logicID);
56 m_writeStmt->setString(3, std::to_string(
item->getErrorBits()));
57 m_writeStmt->executeUpdate();
58 }
catch (SQLException&
e) {
59 throw(std::runtime_error(
"RunCrystalErrorsDat::writeDB(): " +
e.getMessage()));
64 this->checkConnection();
67 iov->setConnection(m_env, m_conn);
68 int iovID = iov->fetchID();
75 Statement* stmt = m_conn->createStatement();
78 "SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
79 "to_char(d.error_bits) "
80 "FROM channelview cv JOIN run_crystal_errors_dat d "
81 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
82 "WHERE d.iov_id = :iov_id");
83 stmt->setInt(1, iovID);
84 ResultSet* rset = stmt->executeQuery();
86 std::pair<EcalLogicID, RunCrystalErrorsDat>
p;
88 while (rset->next()) {
96 dat.
setErrorBits(boost::lexical_cast<uint64_t>(rset->getString(7)));
101 m_conn->terminateStatement(stmt);
103 }
catch (SQLException&
e) {
104 throw(std::runtime_error(
"RunCrystalErrorsDat::fetchData(): " +
e.getMessage()));