36 for( std::map<std::string, std::string >::const_iterator ci=
37 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
39 if(ci->first==
"DCU_CONFIGURATION_ID") setConfigTag(ci->second);
48 this->checkConnection();
50 m_readStmt = m_conn->createStatement();
51 m_readStmt->setSQL(
"select ecal_dcu_config_sq.NextVal from dual");
52 ResultSet* rset = m_readStmt->executeQuery();
53 while (rset->next ()){
54 result= rset->getInt(1);
56 m_conn->terminateStatement(m_readStmt);
60 throw(std::runtime_error(
"ODDCUConfig::fetchNextId(): "+e.getMessage()));
69 this->checkConnection();
70 int next_id=fetchNextId();
73 m_writeStmt = m_conn->createStatement();
74 m_writeStmt->setSQL(
"INSERT INTO ECAL_DCU_CONFIGURATION ( dcu_configuration_id, dcu_tag ) " 77 m_writeStmt->setInt(1, next_id);
81 throw(std::runtime_error(
"ODDCUConfig::prepareWrite(): "+e.getMessage()));
90 this->checkConnection();
95 m_writeStmt->setString(2, this->getConfigTag());
97 m_writeStmt->executeUpdate();
101 throw(std::runtime_error(
"ODDCUConfig::writeDB(): "+e.getMessage()));
104 if (!this->fetchID()) {
105 throw(std::runtime_error(
"ODDCUConfig::writeDB: Failed to write"));
116 this->checkConnection();
118 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
119 throw(std::runtime_error(
"ODDCUConfig::fetchData(): no Id defined for this ODDCUConfig "));
124 m_readStmt->setSQL(
"SELECT * " 125 "FROM ECAL_DCU_CONFIGURATION " 126 " where ( dcu_configuration_id = :1 or dcu_tag=:2 ) " );
127 m_readStmt->setInt(1,
result->getId());
128 m_readStmt->setString(2,
result->getConfigTag());
129 ResultSet* rset = m_readStmt->executeQuery();
133 result->setId(rset->getInt(1));
134 result->setConfigTag(rset->getString(2));
138 throw(std::runtime_error(
"ODDCUConfig::fetchData(): "+e.getMessage()));
149 this->checkConnection();
152 Statement* stmt = m_conn->createStatement();
153 stmt->setSQL(
"SELECT dcu_configuration_id FROM ecal_dcu_configuration " 154 "WHERE dcu_tag=:dcu_tag " );
156 stmt->setString(1, getConfigTag());
158 ResultSet* rset = stmt->executeQuery();
161 m_ID = rset->getInt(1);
165 m_conn->terminateStatement(stmt);
167 throw(std::runtime_error(
"ODDCUConfig::fetchID: "+e.getMessage()));
int fetchID() noexcept(false)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
oracle::occi::Statement Statement
void prepareWrite() noexcept(false)
oracle::occi::SQLException SQLException
void writeDB() noexcept(false)
int fetchNextId() noexcept(false)
void fetchData(ODDCUConfig *result) noexcept(false)
void setParameters(const std::map< std::string, std::string > &my_keys_map)