41 for( std::map<std::string, std::string >::const_iterator ci=
42 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
44 if(ci->first==
"LTS_CONFIGURATION_ID") setConfigTag(ci->second);
45 if(ci->first==
"NUM_OF_EVENTS") setNumberOfEvents(atoi(ci->second.c_str()) );
46 if(ci->first==
"RATE") setRate(atoi(ci->second.c_str() ));
47 if(ci->first==
"TRIGGER_TYPE") setTriggerType(ci->second );
48 if(ci->first==
"TRIG_LOC_L1_DELAY") setTrigLocL1Delay(atoi(ci->second.c_str() ));
57 this->checkConnection();
59 m_readStmt = m_conn->createStatement();
60 m_readStmt->setSQL(
"select ecal_lts_config_sq.NextVal from dual");
61 ResultSet* rset = m_readStmt->executeQuery();
62 while (rset->next ()){
63 result= rset->getInt(1);
65 m_conn->terminateStatement(m_readStmt);
69 throw(std::runtime_error(
"ODLTSConfig::fetchNextId(): "+e.getMessage()));
78 this->checkConnection();
79 int next_id=fetchNextId();
82 m_writeStmt = m_conn->createStatement();
83 m_writeStmt->setSQL(
"INSERT INTO ECAL_LTS_CONFIGURATION ( lts_configuration_id, lts_tag, " 84 "trigger_type, num_of_events, rate, trig_loc_l1_delay ) " 86 ":1, :2, :3, :4 , :5, :6 )");
87 m_writeStmt->setInt(1, next_id);
91 throw(std::runtime_error(
"ODLTSConfig::prepareWrite(): "+e.getMessage()));
100 this->checkConnection();
101 this->checkPrepare();
105 m_writeStmt->setString(2, this->getConfigTag());
106 m_writeStmt->setString(3, this->getTriggerType());
107 m_writeStmt->setInt(4, this->getNumberOfEvents());
108 m_writeStmt->setInt(5, this->getRate());
109 m_writeStmt->setInt(6, this->getTrigLocL1Delay());
111 m_writeStmt->executeUpdate();
115 throw(std::runtime_error(
"ODLTSConfig::writeDB(): "+e.getMessage()));
118 if (!this->fetchID()) {
119 throw(std::runtime_error(
"ODLTSConfig::writeDB: Failed to write"));
130 this->checkConnection();
132 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
133 throw(std::runtime_error(
"ODLTSConfig::fetchData(): no Id defined for this ODLTSConfig "));
138 m_readStmt->setSQL(
"SELECT * " 139 "FROM ECAL_LTS_CONFIGURATION " 140 " where ( lts_configuration_id = :1 or lts_tag=:2 ) " );
141 m_readStmt->setInt(1,
result->getId());
142 m_readStmt->setString(2,
result->getConfigTag());
143 ResultSet* rset = m_readStmt->executeQuery();
147 result->setId(rset->getInt(1));
148 result->setConfigTag(rset->getString(2));
150 result->setTriggerType( rset->getString(3) );
151 result->setNumberOfEvents( rset->getInt(4) );
152 result->setRate( rset->getInt(5) );
153 result->setTrigLocL1Delay( rset->getInt(6) );
157 throw(std::runtime_error(
"ODLTSConfig::fetchData(): "+e.getMessage()));
168 this->checkConnection();
171 Statement* stmt = m_conn->createStatement();
172 stmt->setSQL(
"SELECT lts_configuration_id FROM ecal_lts_configuration " 173 "WHERE lts_tag=:lts_tag " );
175 stmt->setString(1, getConfigTag());
177 ResultSet* rset = stmt->executeQuery();
180 m_ID = rset->getInt(1);
184 m_conn->terminateStatement(stmt);
186 throw(std::runtime_error(
"ODLTSConfig::fetchID: "+e.getMessage()));
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
int fetchNextId() noexcept(false)
void prepareWrite() noexcept(false)
void fetchData(ODLTSConfig *result) noexcept(false)
void setParameters(const std::map< std::string, std::string > &my_keys_map)
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException
int fetchID() noexcept(false)
void writeDB() noexcept(false)