11 using namespace oracle::occi;
41 this->checkConnection();
43 m_readStmt = m_conn->createStatement();
44 m_readStmt->setSQL(
"select FE_CONFIG_TIM_SQ.NextVal from DUAL ");
45 ResultSet* rset = m_readStmt->executeQuery();
46 while (rset->next ()){
47 result= rset->getInt(1);
50 m_conn->terminateStatement(m_readStmt);
54 throw(std::runtime_error(
"FEConfigTimingInfo::fetchNextId(): "+e.getMessage()));
62 this->checkConnection();
66 next_id=fetchNextId();
70 m_writeStmt = m_conn->createStatement();
71 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" ( tim_conf_id, tag, version) "
72 " VALUES ( :1, :2, :3 ) " );
74 m_writeStmt->setInt(1, next_id);
78 throw(std::runtime_error(
"FEConfigTimingInfo::prepareWrite(): "+e.getMessage()));
88 for( std::map<std::string, std::string >::const_iterator ci=
89 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
91 if(ci->first==
"VERSION") setVersion(atoi(ci->second.c_str()) );
92 if(ci->first==
"TAG") setConfigTag(ci->second);
101 this->checkConnection();
102 this->checkPrepare();
107 m_writeStmt->setString(2, this->getConfigTag());
108 m_writeStmt->setInt(3, this->getVersion());
110 m_writeStmt->executeUpdate();
114 throw(std::runtime_error(
"FEConfigTimingInfo::writeDB(): "+e.getMessage()));
117 if (!this->fetchID()) {
118 throw(std::runtime_error(
"FEConfigTimingInfo::writeDB: Failed to write"));
128 this->checkConnection();
130 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
131 throw(std::runtime_error(
"FEConfigTimingInfo::fetchData(): no Id defined for this FEConfigTimingInfo "));
137 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
138 " where ( tim_conf_id= :1 or (tag=:2 AND version=:3 ) )" );
139 m_readStmt->setInt(1,
result->getId());
140 m_readStmt->setString(2,
result->getConfigTag());
141 m_readStmt->setInt(3,
result->getVersion());
142 ResultSet* rset = m_readStmt->executeQuery();
148 result->setId(rset->getInt(1));
149 result->setConfigTag(rset->getString(2));
150 result->setVersion(rset->getInt(3));
151 Date dbdate = rset->getDate(4);
155 throw(std::runtime_error(
"FEConfigTimingInfo::fetchData(): "+e.getMessage()));
162 this->checkConnection();
167 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
168 " where tim_conf_id = ( select max( tim_conf_id) from "+ getTable() +
" ) " );
169 ResultSet* rset = m_readStmt->executeQuery();
173 result->setId(rset->getInt(1));
174 result->setConfigTag(rset->getString(2));
175 result->setVersion(rset->getInt(3));
176 Date dbdate = rset->getDate(4);
180 throw(std::runtime_error(
"FEConfigTimingInfo::fetchData(): "+e.getMessage()));
191 this->checkConnection();
194 Statement* stmt = m_conn->createStatement();
195 stmt->setSQL(
"SELECT tim_conf_id FROM "+ getTable()+
196 " WHERE tag=:1 and version=:2 " );
198 stmt->setString(1, getConfigTag() );
199 stmt->setInt(2, getVersion() );
204 m_ID = rset->getInt(1);
208 m_conn->terminateStatement(stmt);
210 throw(std::runtime_error(
"FEConfigTimingInfo::fetchID: "+e.getMessage()));
221 this->checkConnection();
226 Statement* stmt = m_conn->createStatement();
228 stmt->setSQL(
"SELECT * FROM "+ getTable()+
" WHERE tim_conf_id = :1");
233 this->setId(rset->getInt(1));
234 this->setConfigTag(rset->getString(2));
235 this->setVersion(rset->getInt(3));
236 Date dbdate = rset->getDate(4);
237 this->setDBTime( dh.
dateToTm( dbdate ));
239 throw(std::runtime_error(
"FEConfigTimingInfo::setByID: Given tim_conf_id is not in the database"));
242 m_conn->terminateStatement(stmt);
244 throw(std::runtime_error(
"FEConfigTimingInfo::setByID: "+e.getMessage()));
void fetchLastData(FEConfigTimingInfo *result) noexcept(false)
static unsigned int getId(void)
void writeDB() noexcept(false)
void prepareWrite() noexcept(false)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
void setByID(int id) noexcept(false)
oracle::occi::Statement Statement
void fetchData(FEConfigTimingInfo *result) noexcept(false)
oracle::occi::ResultSet ResultSet
int fetchID() noexcept(false)
oracle::occi::SQLException SQLException
int fetchNextId() noexcept(false)
void setParameters(const std::map< std::string, std::string > &my_keys_map)
volatile std::atomic< bool > shutdown_flag false
Tm dateToTm(oracle::occi::Date &date) const