17 m_writeStmt =
nullptr;
42 this->checkConnection();
44 m_readStmt = m_conn->createStatement();
45 m_readStmt->setSQL(
"select FE_CONFIG_WEIGHT_SQ.NextVal from DUAL ");
46 ResultSet* rset = m_readStmt->executeQuery();
47 while (rset->next ()){
48 result= rset->getInt(1);
51 m_conn->terminateStatement(m_readStmt);
55 throw(std::runtime_error(
"FEConfigWeightInfo::fetchNextId(): "+e.getMessage()));
63 this->checkConnection();
67 next_id=fetchNextId();
71 m_writeStmt = m_conn->createStatement();
72 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" ( wei_conf_id, tag, version, number_of_groups) " 73 " VALUES ( :1, :2, :3 , :4) " );
75 m_writeStmt->setInt(1, next_id);
79 throw(std::runtime_error(
"FEConfigWeightInfo::prepareWrite(): "+e.getMessage()));
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);
94 if(ci->first==
"NUMBER_OF_GROUPS") setNumberOfGroups(atoi(ci->second.c_str()) );
103 this->checkConnection();
104 this->checkPrepare();
109 m_writeStmt->setString(2, this->getConfigTag());
110 m_writeStmt->setInt(3, this->getVersion());
111 m_writeStmt->setInt(4, this->getNumberOfGroups());
113 m_writeStmt->executeUpdate();
117 throw(std::runtime_error(
"FEConfigWeightInfo::writeDB(): "+e.getMessage()));
120 if (!this->fetchID()) {
121 throw(std::runtime_error(
"FEConfigWeightInfo::writeDB: Failed to write"));
131 this->checkConnection();
133 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
134 throw(std::runtime_error(
"FEConfigWeightInfo::fetchData(): no Id defined for this FEConfigWeightInfo "));
140 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
141 " where ( wei_conf_id= :1 or (tag=:2 AND version=:3 ) )" );
142 m_readStmt->setInt(1,
result->getId());
143 m_readStmt->setString(2,
result->getConfigTag());
144 m_readStmt->setInt(3,
result->getVersion());
145 ResultSet* rset = m_readStmt->executeQuery();
151 result->setId(rset->getInt(1));
152 result->setConfigTag(rset->getString(2));
153 result->setVersion(rset->getInt(3));
154 result->setNumberOfGroups(rset->getInt(4));
155 Date dbdate = rset->getDate(5);
159 throw(std::runtime_error(
"FEConfigWeightInfo::fetchData(): "+e.getMessage()));
166 this->checkConnection();
171 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
172 " where wei_conf_id = ( select max( wei_conf_id) from "+ getTable() +
" ) " );
173 ResultSet* rset = m_readStmt->executeQuery();
177 result->setId(rset->getInt(1));
178 result->setConfigTag(rset->getString(2));
179 result->setVersion(rset->getInt(3));
180 result->setNumberOfGroups(rset->getInt(4));
181 Date dbdate = rset->getDate(5);
185 throw(std::runtime_error(
"FEConfigWeightInfo::fetchData(): "+e.getMessage()));
196 this->checkConnection();
199 Statement* stmt = m_conn->createStatement();
200 stmt->setSQL(
"SELECT wei_conf_id FROM "+ getTable()+
201 " WHERE tag=:1 and version=:2 " );
203 stmt->setString(1, getConfigTag() );
204 stmt->setInt(2, getVersion() );
206 ResultSet* rset = stmt->executeQuery();
209 m_ID = rset->getInt(1);
213 m_conn->terminateStatement(stmt);
215 throw(std::runtime_error(
"FEConfigWeightInfo::fetchID: "+e.getMessage()));
226 this->checkConnection();
231 Statement* stmt = m_conn->createStatement();
233 stmt->setSQL(
"SELECT * FROM fe_config_weight_info WHERE wei_conf_id = :1");
236 ResultSet* rset = stmt->executeQuery();
238 this->setId(rset->getInt(1));
239 this->setConfigTag(rset->getString(2));
240 this->setVersion(rset->getInt(3));
241 this->setNumberOfGroups(rset->getInt(4));
242 Date dbdate = rset->getDate(5);
243 this->setDBTime( dh.
dateToTm( dbdate ));
245 throw(std::runtime_error(
"FEConfigWeightInfo::setByID: Given config_id is not in the database"));
248 m_conn->terminateStatement(stmt);
250 throw(std::runtime_error(
"FEConfigWeightInfo::setByID: "+e.getMessage()));
void fetchLastData(FEConfigWeightInfo *result) noexcept(false)
static unsigned int getId()
~FEConfigWeightInfo() override
void fetchData(FEConfigWeightInfo *result) noexcept(false)
void writeDB() noexcept(false)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
int fetchNextId() noexcept(false)
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException
void setParameters(const std::map< std::string, std::string > &my_keys_map)
void prepareWrite() noexcept(false) override
void setByID(int id) noexcept(false)
Tm dateToTm(oracle::occi::Date &date) const
int fetchID() noexcept(false)