9 using namespace oracle::occi;
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(
"ODVfeToRejectInfo::fetchNextId(): "+e.getMessage()));
59 throw(std::runtime_error)
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(
"ODVfeToRejectInfo::prepareWrite(): "+e.getMessage()));
87 for( std::map<std::string, std::string >::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);
98 throw(std::runtime_error)
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(
"ODVfeToRejectInfo::writeDB(): "+e.getMessage()));
116 if (!this->fetchID()) {
117 throw(std::runtime_error(
"ODVfeToRejectInfo::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 <<
"ODVfeToRejectInfo>>WARNING version is "<< getVersion()<< endl;
131 throw(std::runtime_error)
133 this->checkConnection();
135 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
136 throw(std::runtime_error(
"ODVfeToRejectInfo::fetchData(): no Id defined for this ODVfeToRejectInfo "));
143 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
144 " where rec_id = :1 ");
145 m_readStmt->setInt(1,
result->getId());
146 }
else if (
result->getConfigTag()!=
"") {
148 if(
result->getVersion() !=0){
149 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
151 " and version = :version " );
152 m_readStmt->setString(1,
result->getConfigTag());
153 m_readStmt->setInt(2,
result->getVersion());
156 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
157 " WHERE tag = :1 and version= (select max(version) from "+getTable() +
" where tag=:2) " );
158 m_readStmt->setString(1,
result->getConfigTag());
159 m_readStmt->setString(2,
result->getConfigTag());
164 throw(std::runtime_error(
"ODVfeToRejectInfo::fetchData(): no Id defined for this record "));
168 ResultSet* rset = m_readStmt->executeQuery();
174 result->setId(rset->getInt(1));
175 result->setConfigTag(rset->getString(2));
176 result->setVersion(rset->getInt(3));
179 throw(std::runtime_error(
"ODVfeToRejectInfo::fetchData(): "+e.getMessage()));
190 this->checkConnection();
193 Statement* stmt = m_conn->createStatement();
194 stmt->setSQL(
"SELECT rec_id FROM "+ getTable()+
195 " WHERE tag=:1 and version=:2 " );
197 stmt->setString(1, getConfigTag() );
198 stmt->setInt(2, getVersion() );
203 m_ID = rset->getInt(1);
207 m_conn->terminateStatement(stmt);
209 throw(std::runtime_error(
"ODVfeToRejectInfo::fetchID: "+e.getMessage()));
static unsigned int getId(void)
void fetchData(ODVfeToRejectInfo *result)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
oracle::occi::Statement Statement
oracle::occi::ResultSet ResultSet
void setParameters(std::map< std::string, std::string > my_keys_map)
oracle::occi::SQLException SQLException