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);
54 throw(std::runtime_error(
"ODFEWeightsInfo::fetchNextId(): "+e.getMessage()));
62 this->checkConnection();
66 next_id=fetchNextId();
70 m_writeStmt = m_conn->createStatement();
71 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" ( rec_id, tag, version ) " 72 " VALUES ( :1, :2, :3 ) " );
74 m_writeStmt->setInt(1, next_id);
78 throw(std::runtime_error(
"ODFEWeightsInfo::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());
109 m_writeStmt->executeUpdate();
113 throw(std::runtime_error(
"ODFEWeightsInfo::writeDB(): "+e.getMessage()));
117 if (!this->fetchID()) {
118 throw(std::runtime_error(
"ODFEWeightsInfo::writeDB: Failed to write"));
120 int old_version=this->getVersion();
121 m_readStmt = m_conn->createStatement();
122 this->fetchData (
this);
123 m_conn->terminateStatement(m_readStmt);
124 if(this->getVersion()!=old_version)
std::cout <<
"ODFEWeightsInfo>>WARNING version is "<< getVersion()<< endl;
134 this->checkConnection();
136 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
137 throw(std::runtime_error(
"ODFEWeightsInfo::fetchData(): no Id defined for this ODFEWeightsInfo "));
143 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
144 " where rec_id = :1 ");
145 m_readStmt->setInt(1,
result->getId());
146 }
else if (
result->getConfigTag()!=
"") {
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(
"ODFEWeightsInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
156 ResultSet* rset = m_readStmt->executeQuery();
162 result->setId(rset->getInt(1));
163 result->setConfigTag(rset->getString(2));
164 result->setVersion(rset->getInt(3));
167 throw(std::runtime_error(
"ODFEWeightsInfo::fetchData(): "+e.getMessage()));
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() );
191 m_ID = rset->getInt(1);
195 m_conn->terminateStatement(stmt);
197 throw(std::runtime_error(
"ODFEWeightsInfo::fetchID: "+e.getMessage()));
static unsigned int getId(void)
void prepareWrite() noexcept(false)
void fetchData(ODFEWeightsInfo *result) noexcept(false)
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
oracle::occi::ResultSet ResultSet
oracle::occi::SQLException SQLException
int fetchNextId() noexcept(false)
void writeDB() noexcept(false)