16 m_writeStmt =
nullptr;
41 this->checkConnection();
43 m_readStmt = m_conn->createStatement();
44 m_readStmt->setSQL(
"select COND2CONF_INFO_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);
51 std::cout <<
" the id is going to be : "<< result<< endl;
55 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::fetchNextId(): ")+getOraMessage(&e)));
63 this->checkConnection();
67 next_id=fetchNextId();
71 m_writeStmt = m_conn->createStatement();
72 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" ( rec_id, tag, version) " 73 " VALUES ( :1, :2, :3 ) " );
75 m_writeStmt->setInt(1, next_id);
79 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::prepareWrite(): ")+getOraMessage(&e)));
89 for( std::map<std::string, std::string >::const_iterator ci=
90 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
92 if(ci->first==
"VERSION") setVersion(atoi(ci->second.c_str()) );
93 if(ci->first==
"TAG") setConfigTag(ci->second);
102 this->checkConnection();
103 this->checkPrepare();
108 m_writeStmt->setString(2, this->getConfigTag());
109 m_writeStmt->setInt(3, this->getVersion());
111 m_writeStmt->executeUpdate();
115 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::writeDB(): ")+getOraMessage(&e)));
119 if (!this->fetchID()) {
120 throw(std::runtime_error(
"ODFEDelaysInfo::writeDB: Failed to write"));
122 int old_version=this->getVersion();
123 m_readStmt = m_conn->createStatement();
124 this->fetchData (
this);
125 m_conn->terminateStatement(m_readStmt);
126 if(this->getVersion()!=old_version)
std::cout <<
"ODFEDelaysInfo>>WARNING version is "<< getVersion()<< endl;
135 this->checkConnection();
138 if(
result->getId()==0 && (
result->getConfigTag().empty()) ){
139 throw(std::runtime_error(
"ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
144 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
145 " where rec_id = :1 ");
146 m_readStmt->setInt(1,
result->getId());
147 }
else if (!
result->getConfigTag().empty()) {
148 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
149 " where tag=:1 AND version=:2 " );
150 m_readStmt->setString(1,
result->getConfigTag());
151 m_readStmt->setInt(2,
result->getVersion());
154 throw(std::runtime_error(
"ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
157 ResultSet* rset = m_readStmt->executeQuery();
162 result->setId(rset->getInt(1));
163 result->setConfigTag(getOraString(rset,2));
164 result->setVersion(rset->getInt(3));
167 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::fetchData(): ")+getOraMessage(&e)));
178 this->checkConnection();
181 Statement* stmt = m_conn->createStatement();
182 stmt->setSQL(
"SELECT rec_id FROM "+ getTable()+
183 "WHERE tag=:1 and version=:2 " );
185 stmt->setString(1, getConfigTag() );
186 stmt->setInt(2, getVersion() );
188 ResultSet* rset = stmt->executeQuery();
191 m_ID = rset->getInt(1);
195 m_conn->terminateStatement(stmt);
197 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::fetchID: ")+getOraMessage(&e)));
static unsigned int getId()
void writeDB() noexcept(false)
int fetchID() noexcept(false)
void fetchData(ODFEDelaysInfo *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
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException
~ODFEDelaysInfo() override
int fetchNextId() noexcept(false)