53 this->checkConnection();
55 m_readStmt = m_conn->createStatement();
56 m_readStmt->setSQL(
"select fe_config_main_sq.NextVal from dual");
57 ResultSet* rset = m_readStmt->executeQuery();
58 while (rset->next ()){
59 result= rset->getInt(1);
61 m_conn->terminateStatement(m_readStmt);
65 throw(std::runtime_error(
"FEConfigMainInfo::fetchNextId(): "+e.getMessage()));
78 this->checkConnection();
83 std::cout <<
" tag/version " << getConfigTag() <<
"/"<<getVersion() << std::endl;
86 Statement* stmt = m_conn->createStatement();
88 stmt->setSQL(
"SELECT conf_id from FE_CONFIG_MAIN " 90 " and version = :version " );
91 stmt->setString(1, m_config_tag);
92 stmt->setInt(2, m_version);
93 std::cout<<
" using query with version " <<endl;
96 stmt->setSQL(
"SELECT conf_id from FE_CONFIG_MAIN " 97 "WHERE tag = :1 and version= (select max(version) from FE_CONFIG_MAIN where tag=:2) " );
98 stmt->setString(1, m_config_tag);
99 stmt->setString(2, m_config_tag);
100 std::cout<<
" using query WITHOUT version " <<endl;
103 ResultSet* rset = stmt->executeQuery();
106 m_ID = rset->getInt(1);
111 m_conn->terminateStatement(stmt);
113 throw(std::runtime_error(
"FEConfigMainInfo::fetchID: "+e.getMessage()));
125 this->checkConnection();
128 int next_id=fetchNextId();
131 m_writeStmt = m_conn->createStatement();
132 m_writeStmt->setSQL(
"INSERT INTO fe_config_main (conf_id, ped_conf_id, lin_conf_id, lut_conf_id, fgr_conf_id, sli_conf_id, wei_conf_id, spi_conf_id, tim_conf_id, bxt_conf_id, btt_conf_id, bst_conf_id, tag, version, description) " 133 " VALUES (:1, :2, :3 , :4, :5, :6 ,:7, :8, :9, :10, :11, :12, :13, :14, :15 )");
135 m_writeStmt->setInt(1, next_id);
139 throw(std::runtime_error(
"FEConfigMainInfo::prepareWrite(): "+e.getMessage()));
148 this->checkConnection();
149 this->checkPrepare();
157 m_writeStmt->setInt(2, this->getPedId());
158 m_writeStmt->setInt(3, this->getLinId());
159 m_writeStmt->setInt(4, this->getLUTId());
160 m_writeStmt->setInt(5, this->getFgrId());
161 m_writeStmt->setInt(6, this->getSliId());
162 m_writeStmt->setInt(7, this->getWeiId());
163 m_writeStmt->setInt(8, this->getSpiId());
164 m_writeStmt->setInt(9, this->getTimId());
165 m_writeStmt->setInt(10, this->getBxtId());
166 m_writeStmt->setInt(11, this->getBttId());
167 m_writeStmt->setInt(12, this->getBstId());
168 m_writeStmt->setString(13, this->getConfigTag());
169 m_writeStmt->setInt(14, this->getVersion());
170 m_writeStmt->setString(15, this->getDescription());
171 m_writeStmt->executeUpdate();
175 throw(std::runtime_error(
"FEConfigMainInfo::writeDB: "+e.getMessage()));
178 if (!this->fetchID()) {
179 throw(std::runtime_error(
"FEConfigMainInfo::writeDB: Failed to write"));
183 cout<<
"FEConfigMainInfo::writeDB>> done inserting FEConfigMainInfo with id="<<m_ID<<endl;
194 this->checkConnection();
199 Statement* stmt = m_conn->createStatement();
200 stmt->setSQL(
"SELECT max(conf_id) FROM fe_config_main ");
201 ResultSet* rset = stmt->executeQuery();
204 m_ID = rset->getInt(1);
208 m_conn->terminateStatement(stmt);
210 throw(std::runtime_error(
"ODRunConfigInfo::fetchIDLast: "+e.getMessage()));
221 this->checkConnection();
225 cout<<
"FEConfigMainInfo::setByID called for id "<<
id<<endl;
228 Statement* stmt = m_conn->createStatement();
230 stmt->setSQL(
"SELECT * FROM FE_CONFIG_MAIN WHERE conf_id = :1 ");
233 ResultSet* rset = stmt->executeQuery();
235 setId( rset->getInt(1) );
236 setPedId( rset->getInt(2) );
237 setLinId( rset->getInt(3) );
238 setLUTId( rset->getInt(4) );
239 setFgrId( rset->getInt(5) );
240 setSliId( rset->getInt(6) );
241 setWeiId( rset->getInt(7) );
242 setSpiId( rset->getInt(8) );
243 setTimId( rset->getInt(9) );
244 setBxtId( rset->getInt(10) );
245 setBttId( rset->getInt(11) );
246 setBstId( rset->getInt(12) );
247 setConfigTag( rset->getString(13) );
248 setVersion( rset->getInt(14) );
249 setDescription( rset->getString(15) );
250 Date dbdate = rset->getDate(16);
254 throw(std::runtime_error(
"FEConfigMainInfo::setByID: Given cycle_id is not in the database"));
256 m_conn->terminateStatement(stmt);
258 throw(std::runtime_error(
"FEConfigMainInfo::setByID: "+e.getMessage()));
265 {
std::cout <<
" ### 1 getId from FEConfigMainInfo = " <<
result->getId() << std::endl;
268 this->checkConnection();
281 m_readStmt->setSQL(
"SELECT * FROM FE_CONFIG_MAIN WHERE conf_id = :1 ");
283 std::cout <<
" ### 2 getId from FEConfigMainInfo = " <<
result->getId() << std::endl;
286 m_readStmt->setInt(1,
result->getId());
287 ResultSet* rset = m_readStmt->executeQuery();
291 result->setId( rset->getInt(1) );
293 setPedId( rset->getInt(2) );
294 setLinId( rset->getInt(3) );
295 setLUTId( rset->getInt(4) );
296 setFgrId( rset->getInt(5) );
297 setSliId( rset->getInt(6) );
298 setWeiId( rset->getInt(7) );
299 setSpiId( rset->getInt(8) );
300 setTimId( rset->getInt(9) );
301 setBxtId( rset->getInt(10) );
302 setBttId( rset->getInt(11) );
303 setBstId( rset->getInt(12) );
305 result->setConfigTag( rset->getString(13) );
306 result->setVersion( rset->getInt(14) );
307 result->setDescription( rset->getString(15) );
308 Date dbdate = rset->getDate(16);
312 throw(std::runtime_error(
"FEConfigMainInfo::fetchData(): "+e.getMessage()));
324 terminateWriteStatement();
325 }
catch (std::runtime_error &
e) {
330 throw(std::runtime_error(
"FEConfigMainInfo::insertConfig: Unknown exception caught"));
void setByID(int id) noexcept(false)
int fetchNextId() noexcept(false)
int fetchID() noexcept(false)
void writeDB() noexcept(false)
void insertConfig() noexcept(false)
void fetchData(FEConfigMainInfo *result) noexcept(false)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
void prepareWrite() noexcept(false)
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException
Tm dateToTm(oracle::occi::Date &date) const
int fetchIDLast() noexcept(false)