16 m_writeStmt =
nullptr;
49 this->checkConnection();
51 m_readStmt = m_conn->createStatement();
52 m_readStmt->setSQL(
"select COND2CONF_INFO_SQ.NextVal from DUAL ");
53 ResultSet* rset = m_readStmt->executeQuery();
54 while (rset->next ()){
55 result= rset->getInt(1);
58 m_conn->terminateStatement(m_readStmt);
62 throw(std::runtime_error(
"ODCond2ConfInfo::fetchNextId(): "+e.getMessage()));
75 this->checkConnection();
76 m_readStmt = m_conn->createStatement();
77 m_readStmt->setSQL(
"select def_id from COND2CONF_TYPE_DEF where rec_type="+getType());
78 ResultSet* rset = m_readStmt->executeQuery();
79 while (rset->next ()){
80 m_typ_id= rset->getInt(1);
82 m_conn->terminateStatement(m_readStmt);
86 throw(std::runtime_error(
"ODCond2ConfInfo::fetchParents(): "+e.getMessage()));
91 if(getLocation()!=
""){
93 this->checkConnection();
94 m_readStmt = m_conn->createStatement();
95 m_readStmt->setSQL(
"select def_id from location_def where location="+getLocation());
96 ResultSet* rset = m_readStmt->executeQuery();
97 while (rset->next ()){
98 m_loc_id= rset->getInt(1);
100 m_conn->terminateStatement(m_readStmt);
102 throw(std::runtime_error(
"ODCond2ConfInfo::fetchParents(): "+e.getMessage()));
112 this->checkConnection();
116 next_id=fetchNextId();
121 m_writeStmt = m_conn->createStatement();
122 m_writeStmt->setSQL(
"INSERT INTO "+getTable()+
" ( rec_id, rec_type_id, rec_date, " 123 "location_id, run_number, short_desc ) " 124 " VALUES ( :1, :2, :3 , :4, :5, :6 ) " );
126 m_writeStmt->setInt(1, next_id);
127 m_writeStmt->setInt(3, m_typ_id);
128 m_writeStmt->setInt(4, m_loc_id);
133 throw(std::runtime_error(
"ODCond2ConfInfo::prepareWrite(): "+e.getMessage()));
143 for( std::map<std::string, std::string >::const_iterator ci=
144 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
149 std::cout<<
"method not yet implemented"<< std::endl;
157 this->checkConnection();
158 this->checkPrepare();
162 if (m_rec_time.isNull()) {
164 m_rec_time =
Tm(very_old_time);
169 m_writeStmt->setDate(3, dh.
tmToDate(this->m_rec_time));
171 m_writeStmt->setString(6, this->getDescription());
173 m_writeStmt->executeUpdate();
177 throw(std::runtime_error(
"ODCond2ConfInfo::writeDB(): "+e.getMessage()));
180 if (!this->fetchID()) {
181 throw(std::runtime_error(
"ODCond2ConfInfo::writeDB: Failed to write"));
190 this->checkConnection();
197 throw(std::runtime_error(
"ODCond2ConfInfo::fetchData(): no Id defined for this ODCond2ConfInfo "));
202 m_readStmt->setSQL(
"SELECT rec_id, REC_TYPE, rec_date, location, " 203 "run_number, short_desc, db_timestamp FROM " + getTable() +
" , COND2CONF_TYPE_DEF , location_def " 204 " where rec_id = :1 AND COND2CONF_TYPE_DEF.def_id=" 205 +getTable()+
".REC_TYPE_ID AND location_def.def_id=LOCATION_ID ");
206 m_readStmt->setInt(1,
result->getId());
207 ResultSet* rset = m_readStmt->executeQuery();
219 result->setType(rset->getString(2));
220 Date startDate = rset->getDate(3);
221 result->setLocation(rset->getString(4));
222 result->setRunNumber(rset->getInt(5));
223 result->setDescription(rset->getString(6));
224 Date endDate = rset->getDate(7);
226 m_rec_time = dh.
dateToTm( startDate );
230 throw(std::runtime_error(
"ODCond2ConfInfo::fetchData(): "+e.getMessage()));
241 this->checkConnection();
247 Statement* stmt = m_conn->createStatement();
248 stmt->setSQL(
"SELECT rec_id FROM "+ getTable()+
249 "WHERE rec_type_id=:1 and (run_number=:2 or short_desc=:3 ) order by rec_id DESC " );
251 stmt->setInt(1, m_typ_id );
253 stmt->setString(3, getDescription() );
255 ResultSet* rset = stmt->executeQuery();
258 m_ID = rset->getInt(1);
262 m_conn->terminateStatement(stmt);
264 throw(std::runtime_error(
"ODCond2ConfInfo::fetchID: "+e.getMessage()));
void setParameters(const std::map< std::string, std::string > &my_keys_map)
int fetchNextId() noexcept(false)
void writeDB() noexcept(false)
static unsigned int getId()
void prepareWrite() noexcept(false) override
void fetchParents() noexcept(false)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
oracle::occi::Date tmToDate(const Tm &inTm) const
~ODCond2ConfInfo() override
oracle::occi::Statement Statement
def getRunNumber(filename)
oracle::occi::SQLException SQLException
Tm dateToTm(oracle::occi::Date &date) const
int fetchID() noexcept(false)
void fetchData(ODCond2ConfInfo *result) noexcept(false)