15 m_writeStmt =
nullptr;
42 this->checkConnection();
44 m_readStmt = m_conn->createStatement();
45 m_readStmt->setSQL(
"select ecal_scan_config_sq.NextVal from dual");
46 ResultSet* rset = m_readStmt->executeQuery();
47 while (rset->next ()){
48 result= rset->getInt(1);
50 m_conn->terminateStatement(m_readStmt);
54 throw(std::runtime_error(
"ODScanConfig::fetchNextId(): "+e.getMessage()));
65 for( std::map<std::string, std::string >::const_iterator ci=
66 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
68 if(ci->first==
"SCAN_ID") setConfigTag(ci->second);
69 if(ci->first==
"TYPE_ID") setTypeId(atoi(ci->second.c_str()) );
70 if(ci->first==
"TYPE" || ci->first==
"SCAN_TYPE") setScanType(ci->second );
71 if(ci->first==
"FROM" ||ci->first==
"FROM_VAL" ) setFromVal(atoi(ci->second.c_str() ));
72 if(ci->first==
"TO" ||ci->first==
"TO_VAL" ) setToVal(atoi(ci->second.c_str() ));
73 if(ci->first==
"STEP") setStep(atoi(ci->second.c_str() ));
82 this->checkConnection();
83 int next_id=fetchNextId();
86 m_writeStmt = m_conn->createStatement();
87 m_writeStmt->setSQL(
"INSERT INTO ECAL_scan_dat ( scan_id, scan_tag ," 88 " type_id, scan_type , FROM_VAL , TO_VAL, STEP )" 89 " VALUES ( :1, :2, :3, :4, :5, :6, :7)");
90 m_writeStmt->setInt(1, next_id);
94 throw(std::runtime_error(
"ODScanConfig::prepareWrite(): "+e.getMessage()));
101 this->checkConnection();
102 this->checkPrepare();
107 m_writeStmt->setString(2, this->getConfigTag());
109 m_writeStmt->setInt(3, this->getTypeId());
110 m_writeStmt->setString(4, this->getScanType() );
111 m_writeStmt->setInt(5, this->getFromVal() );
112 m_writeStmt->setInt(6, this->getToVal() );
113 m_writeStmt->setInt(7, this->getStep() );
115 m_writeStmt->executeUpdate();
119 throw(std::runtime_error(
"ODScanConfig::writeDB(): "+e.getMessage()));
122 if (!this->fetchID()) {
123 throw(std::runtime_error(
"ODScanConfig::writeDB: Failed to write"));
134 this->checkConnection();
136 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
137 throw(std::runtime_error(
"ODScanConfig::fetchData(): no Id defined for this ODScanConfig "));
142 m_readStmt->setSQL(
"SELECT * " 143 "FROM ECAL_SCAN_DAT " 144 " where (scan_id = :1 or scan_tag=:2 )" );
145 m_readStmt->setInt(1,
result->getId());
146 m_readStmt->setString(2,
result->getConfigTag());
148 ResultSet* rset = m_readStmt->executeQuery();
153 result->setId(rset->getInt(1));
154 result->setConfigTag(rset->getString(2));
155 result->setTypeId( rset->getInt(3) );
156 result->setScanType( rset->getString(4) );
157 result->setFromVal( rset->getInt(5) );
158 result->setToVal( rset->getInt(6) );
159 result->setStep( rset->getInt(7) );
162 throw(std::runtime_error(
"ODScanConfig::fetchData(): "+e.getMessage()));
173 this->checkConnection();
176 Statement* stmt = m_conn->createStatement();
177 stmt->setSQL(
"SELECT scan_id FROM ecal_scan_dat " 178 "WHERE scan_tag=:scan_tag ");
180 stmt->setString(1, getConfigTag() );
182 ResultSet* rset = stmt->executeQuery();
185 m_ID = rset->getInt(1);
189 m_conn->terminateStatement(stmt);
191 throw(std::runtime_error(
"ODScanConfig::fetchID: "+e.getMessage()));
void setParameters(const std::map< std::string, std::string > &my_keys_map)
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 fetchData(ODScanConfig *result) noexcept(false)
void prepareWrite() noexcept(false) override
int fetchID() noexcept(false)
void writeDB() noexcept(false)