17 m_writeStmt =
nullptr;
41 this->checkConnection();
43 m_readStmt = m_conn->createStatement();
44 m_readStmt->setSQL(
"select FE_CONFIG_SPI_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(
"FEConfigSpikeInfo::fetchNextId(): "+e.getMessage()));
62 this->checkConnection();
66 next_id=fetchNextId();
70 m_writeStmt = m_conn->createStatement();
71 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" ( spi_conf_id, tag, version ) " 72 " VALUES ( :1, :2, :3 ) " );
74 m_writeStmt->setInt(1, next_id);
78 throw(std::runtime_error(
"FEConfigSpikeInfo::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(
"FEConfigSpikeInfo::writeDB(): "+e.getMessage()));
117 if (!this->fetchID()) {
118 throw(std::runtime_error(
"FEConfigSpikeInfo::writeDB: Failed to write"));
128 this->checkConnection();
130 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
131 throw(std::runtime_error(
"FEConfigSpikeInfo::fetchData(): no Id defined for this FEConfigSpikeInfo "));
137 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
138 " where ( spi_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(
"FEConfigSpikeInfo::fetchData(): "+e.getMessage()));
162 this->checkConnection();
167 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
168 " where spi_conf_id = ( select max( spi_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(
"FEConfigSpikeInfo::fetchData(): "+e.getMessage()));
191 this->checkConnection();
194 Statement* stmt = m_conn->createStatement();
195 stmt->setSQL(
"SELECT spi_conf_id FROM "+ getTable()+
196 " WHERE tag=:1 and version=:2 " );
198 stmt->setString(1, getConfigTag() );
199 stmt->setInt(2, getVersion() );
201 ResultSet* rset = stmt->executeQuery();
204 m_ID = rset->getInt(1);
208 m_conn->terminateStatement(stmt);
210 throw(std::runtime_error(
"FEConfigSpikeInfo::fetchID: "+e.getMessage()));
221 this->checkConnection();
226 Statement* stmt = m_conn->createStatement();
228 stmt->setSQL(
"SELECT * FROM "+ getTable()+
" WHERE spi_conf_id = :1");
231 ResultSet* rset = stmt->executeQuery();
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(
"FEConfigSpikeInfo::setByID: Given spi_conf_id is not in the database"));
242 m_conn->terminateStatement(stmt);
244 throw(std::runtime_error(
"FEConfigSpikeInfo::setByID: "+e.getMessage()));
static unsigned int getId()
int fetchNextId() noexcept(false)
void fetchData(FEConfigSpikeInfo *result) noexcept(false)
void setParameters(const std::map< std::string, std::string > &my_keys_map)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
void prepareWrite() noexcept(false) override
~FEConfigSpikeInfo() override
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException
void fetchLastData(FEConfigSpikeInfo *result) noexcept(false)
void setByID(int id) noexcept(false)
Tm dateToTm(oracle::occi::Date &date) const
void writeDB() noexcept(false)
int fetchID() noexcept(false)