13 m_writeStmt =
nullptr;
28 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
29 if (ci->first ==
"DCU_CONFIGURATION_ID")
30 setConfigTag(ci->second);
37 this->checkConnection();
39 m_readStmt = m_conn->createStatement();
40 m_readStmt->setSQL(
"select ecal_dcu_config_sq.NextVal from dual");
41 ResultSet* rset = m_readStmt->executeQuery();
42 while (rset->next()) {
45 m_conn->terminateStatement(m_readStmt);
49 throw(std::runtime_error(
std::string(
"ODDCUConfig::fetchNextId(): ") +
e.getMessage()));
54 this->checkConnection();
55 int next_id = fetchNextId();
58 m_writeStmt = m_conn->createStatement();
60 "INSERT INTO ECAL_DCU_CONFIGURATION ( dcu_configuration_id, dcu_tag ) " 63 m_writeStmt->setInt(1, next_id);
67 throw(std::runtime_error(
std::string(
"ODDCUConfig::prepareWrite(): ") +
e.getMessage()));
72 this->checkConnection();
76 m_writeStmt->setString(2, this->getConfigTag());
78 m_writeStmt->executeUpdate();
81 throw(std::runtime_error(
std::string(
"ODDCUConfig::writeDB(): ") +
e.getMessage()));
84 if (!this->fetchID()) {
85 throw(std::runtime_error(
"ODDCUConfig::writeDB: Failed to write"));
90 this->checkConnection();
92 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
93 throw(std::runtime_error(
"ODDCUConfig::fetchData(): no Id defined for this ODDCUConfig "));
99 "FROM ECAL_DCU_CONFIGURATION " 100 " where ( dcu_configuration_id = :1 or dcu_tag=:2 ) ");
101 m_readStmt->setInt(1,
result->getId());
102 m_readStmt->setString(2,
result->getConfigTag());
103 ResultSet* rset = m_readStmt->executeQuery();
107 result->setId(rset->getInt(1));
108 result->setConfigTag(rset->getString(2));
111 throw(std::runtime_error(
std::string(
"ODDCUConfig::fetchData(): ") +
e.getMessage()));
121 this->checkConnection();
124 Statement* stmt = m_conn->createStatement();
126 "SELECT dcu_configuration_id FROM ecal_dcu_configuration " 127 "WHERE dcu_tag=:dcu_tag ");
129 stmt->setString(1, getConfigTag());
131 ResultSet* rset = stmt->executeQuery();
134 m_ID = rset->getInt(1);
138 m_conn->terminateStatement(stmt);
140 throw(std::runtime_error(
std::string(
"ODDCUConfig::fetchID: ") +
e.getMessage()));
int fetchID() noexcept(false)
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException
void clear(HadCaloObj &c)
void writeDB() noexcept(false)
int fetchNextId() noexcept(false)
void prepareWrite() noexcept(false) override
void fetchData(ODDCUConfig *result) noexcept(false)
void setParameters(const std::map< std::string, std::string > &my_keys_map)