15 m_writeStmt =
nullptr;
40 this->checkConnection();
42 m_readStmt = m_conn->createStatement();
43 m_readStmt->setSQL(
"select COND2CONF_INFO_SQ.NextVal from DUAL ");
44 ResultSet* rset = m_readStmt->executeQuery();
45 while (rset->next ()){
46 result= rset->getInt(1);
49 m_conn->terminateStatement(m_readStmt);
53 throw(std::runtime_error(
std::string(
"FEConfigBadXTInfo::fetchNextId(): ")+getOraMessage(&e)));
61 this->checkConnection();
65 next_id=fetchNextId();
69 m_writeStmt = m_conn->createStatement();
70 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" ( rec_id, tag, version) " 71 " VALUES ( :1, :2, :3 ) " );
73 m_writeStmt->setInt(1, next_id);
77 throw(std::runtime_error(
std::string(
"FEConfigBadXTInfo::prepareWrite(): ")+getOraMessage(&e)));
87 for( std::map<std::string, std::string >::const_iterator ci=
88 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
90 if(ci->first==
"VERSION") setVersion(atoi(ci->second.c_str()) );
91 if(ci->first==
"TAG") setConfigTag(ci->second);
100 this->checkConnection();
101 this->checkPrepare();
106 m_writeStmt->setString(2, this->getConfigTag());
107 m_writeStmt->setInt(3, this->getVersion());
109 m_writeStmt->executeUpdate();
113 throw(std::runtime_error(
std::string(
"FEConfigBadXTInfo::writeDB(): ")+getOraMessage(&e)));
116 if (!this->fetchID()) {
117 throw(std::runtime_error(
"FEConfigBadXTInfo::writeDB: Failed to write"));
119 int old_version=this->getVersion();
120 m_readStmt = m_conn->createStatement();
121 this->fetchData (
this);
122 m_conn->terminateStatement(m_readStmt);
123 if(this->getVersion()!=old_version)
std::cout <<
"FEConfigBadXTInfo>>WARNING version is "<< getVersion()<< endl;
133 this->checkConnection();
135 if(
result->getId()==0 && (
result->getConfigTag().empty()) ){
136 throw(std::runtime_error(
"FEConfigBadXTInfo::fetchData(): no Id defined for this FEConfigBadXTInfo "));
143 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
144 " where rec_id = :1 ");
145 m_readStmt->setInt(1,
result->getId());
146 }
else if (!
result->getConfigTag().empty()) {
147 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
148 " where tag=:1 AND version=:2 " );
149 m_readStmt->setString(1,
result->getConfigTag());
150 m_readStmt->setInt(2,
result->getVersion());
153 throw(std::runtime_error(
"FEConfigBadXTInfo::fetchData(): no Id defined for this record "));
157 ResultSet* rset = m_readStmt->executeQuery();
163 result->setId(rset->getInt(1));
164 result->setConfigTag(getOraString(rset,2));
165 result->setVersion(rset->getInt(3));
168 throw(std::runtime_error(
std::string(
"FEConfigBadXTInfo::fetchData(): ")+getOraMessage(&e)));
179 this->checkConnection();
182 Statement* stmt = m_conn->createStatement();
183 stmt->setSQL(
"SELECT rec_id FROM "+ getTable()+
184 "WHERE tag=:1 and version=:2 " );
186 stmt->setString(1, getConfigTag() );
187 stmt->setInt(2, getVersion() );
189 ResultSet* rset = stmt->executeQuery();
192 m_ID = rset->getInt(1);
196 m_conn->terminateStatement(stmt);
198 throw(std::runtime_error(
std::string(
"FEConfigBadXTInfo::fetchID: ")+getOraMessage(&e)));
static unsigned int getId()
void writeDB() noexcept(false)
int fetchNextId() noexcept(false)
~FEConfigBadXTInfo() override
void setParameters(const std::map< std::string, std::string > &my_keys_map)
int fetchID() noexcept(false)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
oracle::occi::Statement Statement
void fetchData(FEConfigBadXTInfo *result) noexcept(false)
oracle::occi::SQLException SQLException
void prepareWrite() noexcept(false) override