14 m_writeStmt =
nullptr;
34 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
35 if (ci->first ==
"LTS_CONFIGURATION_ID")
36 setConfigTag(ci->second);
37 if (ci->first ==
"NUM_OF_EVENTS")
38 setNumberOfEvents(atoi(ci->second.c_str()));
39 if (ci->first ==
"RATE")
40 setRate(atoi(ci->second.c_str()));
41 if (ci->first ==
"TRIGGER_TYPE")
42 setTriggerType(ci->second);
43 if (ci->first ==
"TRIG_LOC_L1_DELAY")
44 setTrigLocL1Delay(atoi(ci->second.c_str()));
51 this->checkConnection();
53 m_readStmt = m_conn->createStatement();
54 m_readStmt->setSQL(
"select ecal_lts_config_sq.NextVal from dual");
55 ResultSet* rset = m_readStmt->executeQuery();
56 while (rset->next()) {
59 m_conn->terminateStatement(m_readStmt);
63 throw(std::runtime_error(
std::string(
"ODLTSConfig::fetchNextId(): ") +
e.getMessage()));
68 this->checkConnection();
69 int next_id = fetchNextId();
72 m_writeStmt = m_conn->createStatement();
74 "INSERT INTO ECAL_LTS_CONFIGURATION ( lts_configuration_id, lts_tag, " 75 "trigger_type, num_of_events, rate, trig_loc_l1_delay ) " 77 ":1, :2, :3, :4 , :5, :6 )");
78 m_writeStmt->setInt(1, next_id);
82 throw(std::runtime_error(
std::string(
"ODLTSConfig::prepareWrite(): ") +
e.getMessage()));
87 this->checkConnection();
91 m_writeStmt->setString(2, this->getConfigTag());
92 m_writeStmt->setString(3, this->getTriggerType());
93 m_writeStmt->setInt(4, this->getNumberOfEvents());
94 m_writeStmt->setInt(5, this->getRate());
95 m_writeStmt->setInt(6, this->getTrigLocL1Delay());
97 m_writeStmt->executeUpdate();
100 throw(std::runtime_error(
std::string(
"ODLTSConfig::writeDB(): ") +
e.getMessage()));
103 if (!this->fetchID()) {
104 throw(std::runtime_error(
"ODLTSConfig::writeDB: Failed to write"));
109 this->checkConnection();
111 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
112 throw(std::runtime_error(
"ODLTSConfig::fetchData(): no Id defined for this ODLTSConfig "));
118 "FROM ECAL_LTS_CONFIGURATION " 119 " where ( lts_configuration_id = :1 or lts_tag=:2 ) ");
120 m_readStmt->setInt(1,
result->getId());
121 m_readStmt->setString(2,
result->getConfigTag());
122 ResultSet* rset = m_readStmt->executeQuery();
126 result->setId(rset->getInt(1));
127 result->setConfigTag(rset->getString(2));
129 result->setTriggerType(rset->getString(3));
130 result->setNumberOfEvents(rset->getInt(4));
131 result->setRate(rset->getInt(5));
132 result->setTrigLocL1Delay(rset->getInt(6));
135 throw(std::runtime_error(
std::string(
"ODLTSConfig::fetchData(): ") +
e.getMessage()));
145 this->checkConnection();
148 Statement* stmt = m_conn->createStatement();
150 "SELECT lts_configuration_id FROM ecal_lts_configuration " 151 "WHERE lts_tag=:lts_tag ");
153 stmt->setString(1, getConfigTag());
155 ResultSet* rset = stmt->executeQuery();
158 m_ID = rset->getInt(1);
162 m_conn->terminateStatement(stmt);
164 throw(std::runtime_error(
std::string(
"ODLTSConfig::fetchID: ") +
e.getMessage()));
int fetchNextId() 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 clear(HadCaloObj &c)
void writeDB() noexcept(false)
void prepareWrite() noexcept(false) override