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);
54 throw(std::runtime_error(
std::string(
"ODFEPedestalOffsetInfo::fetchNextId(): ")+getOraMessage(&e)));
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(
std::string(
"ODFEPedestalOffsetInfo::prepareWrite(): ")+getOraMessage(&e)));
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(
std::string(
"ODFEPedestalOffsetInfo::writeDB(): ")+getOraMessage(&e)));
119 if (!this->fetchID()) {
120 throw(std::runtime_error(
"ODFEPedestalOffsetInfo::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 <<
"ODFEPedestalOffsetInfo>>WARNING version is "<< getVersion()<< endl;
137 this->checkConnection();
139 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
140 throw(std::runtime_error(
"ODFEPedestalOffsetInfo::fetchData(): no Id defined for this ODFEPedestalOffsetInfo "));
145 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
146 " where rec_id = :1 ");
147 m_readStmt->setInt(1,
result->getId());
148 }
else if (
result->getConfigTag()!=
"") {
149 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
150 " where tag=:1 AND version=:2 " );
151 m_readStmt->setString(1,
result->getConfigTag());
152 m_readStmt->setInt(2,
result->getVersion());
155 throw(std::runtime_error(
"ODFEPedestalOffsetInfo::fetchData(): no Id defined for this record "));
158 ResultSet* rset = m_readStmt->executeQuery();
164 result->setId(rset->getInt(1));
165 result->setConfigTag(getOraString(rset,2));
166 result->setVersion(rset->getInt(3));
169 throw(std::runtime_error(
std::string(
"ODFEPedestalOffsetInfo::fetchData(): ")+getOraMessage(&e)));
176 this->checkConnection();
180 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
181 " where rec_id = ( select max(rec_id) from "+ getTable() +
" ) " );
182 ResultSet* rset = m_readStmt->executeQuery();
186 result->setId(rset->getInt(1));
187 result->setConfigTag(getOraString(rset,2));
188 result->setVersion(rset->getInt(3));
191 throw(std::runtime_error(
std::string(
"ODFEPedestalOffsetInfo::fetchData(): ")+getOraMessage(&e)));
202 this->checkConnection();
205 Statement* stmt = m_conn->createStatement();
206 stmt->setSQL(
"SELECT rec_id FROM "+ getTable()+
207 "WHERE tag=:1 and version=:2 " );
209 stmt->setString(1, getConfigTag() );
210 stmt->setInt(2, getVersion() );
212 ResultSet* rset = stmt->executeQuery();
215 m_ID = rset->getInt(1);
219 m_conn->terminateStatement(stmt);
221 throw(std::runtime_error(
std::string(
"ODFEPedestalOffsetInfo::fetchID: ")+getOraMessage(&e)));
static unsigned int getId()
void setParameters(const std::map< std::string, std::string > &my_keys_map)
void prepareWrite() noexcept(false) override
void writeDB() noexcept(false)
int fetchNextId() noexcept(false)
int fetchID() noexcept(false)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
void fetchData(ODFEPedestalOffsetInfo *result) noexcept(false)
~ODFEPedestalOffsetInfo() override
oracle::occi::Statement Statement
void fetchLastData(ODFEPedestalOffsetInfo *result) noexcept(false)
oracle::occi::SQLException SQLException