34 if (run_seq != m_run_seq) {
51 this->checkConnection();
57 Statement* stmt = m_conn->createStatement();
58 stmt->setSQL(
"SELECT sequence_id from ECAL_sequence_DAT " 59 "WHERE ecal_config_id = :id1 " 60 " and sequence_num = :id2 " );
61 stmt->setInt(1, m_ecal_config_id);
62 stmt->setInt(2, m_seq_num);
64 ResultSet* rset = stmt->executeQuery();
67 m_ID = rset->getInt(1);
71 m_conn->terminateStatement(stmt);
73 throw(std::runtime_error(
"ODRunConfigSeqInfo::fetchID: "+e.getMessage()));
85 this->checkConnection();
90 Statement* stmt = m_conn->createStatement();
91 stmt->setSQL(
"SELECT max(sequence_id) FROM ecal_sequence_dat " );
92 ResultSet* rset = stmt->executeQuery();
95 m_ID = rset->getInt(1);
99 m_conn->terminateStatement(stmt);
101 throw(std::runtime_error(
"ODRunConfigSeqInfo::fetchIDLast: "+e.getMessage()));
112 this->checkConnection();
116 cout<<
"ODRunConfigSeqInfo::setByID called for id "<<
id<<endl;
119 Statement* stmt = m_conn->createStatement();
121 stmt->setSQL(
"SELECT ecal_config_id, sequence_num, num_of_cycles, sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
124 ResultSet* rset = stmt->executeQuery();
126 m_ecal_config_id= rset->getInt(1);
127 m_seq_num=rset->getInt(2);
128 m_cycles=rset->getInt(3);
129 int seq_def_id=rset->getInt(4);
130 m_description= rset->getString(5);
132 m_run_seq.setConnection(m_env, m_conn);
133 m_run_seq.setByID(seq_def_id);
135 throw(std::runtime_error(
"ODRunConfigSeqInfo::setByID: Given config_id is not in the database"));
137 m_conn->terminateStatement(stmt);
139 throw(std::runtime_error(
"ODRunConfigSeqInfo::setByID: "+e.getMessage()));
146 this->checkConnection();
149 m_writeStmt = m_conn->createStatement();
150 m_writeStmt->setSQL(
"INSERT INTO ECAL_SEQUENCE_DAT ( ecal_config_id, " 151 "sequence_num, num_of_cycles, sequence_type_def_id, description ) " 152 "VALUES (:1, :2, :3 , :4, :5 )");
154 throw(std::runtime_error(
"ODRunConfigSeqInfo::prepareWrite(): "+e.getMessage()));
160 this->checkConnection();
161 this->checkPrepare();
174 m_run_seq.setConnection(m_env, m_conn);
175 int seq_def_id = m_run_seq.writeDB();
178 m_writeStmt->setInt(1, this->getEcalConfigId());
179 m_writeStmt->setInt(2, this->getSequenceNumber());
180 m_writeStmt->setInt(3, this->getNumberOfCycles());
181 m_writeStmt->setInt(4,seq_def_id );
182 m_writeStmt->setString(5,this->getDescription() );
184 m_writeStmt->executeUpdate();
187 throw(std::runtime_error(
"ODRunConfigSeqInfo::writeDB(): "+e.getMessage()));
189 if (!this->fetchID()) {
190 throw(std::runtime_error(
"ODRunConfigSeqInfo::writeDB: Failed to write"));
192 cout<<
"ODRunConfigSeqInfo::writeDB>> done inserting ODRunConfigSeqInfo with id="<<m_ID<<endl;
210 this->checkConnection();
219 m_readStmt->setSQL(
"SELECT ecal_config_id, sequence_num, num_of_cycles, " 220 "sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
222 m_readStmt->setInt(1,
result->getId());
223 ResultSet* rset = m_readStmt->executeQuery();
227 result->setEcalConfigId( rset->getInt(1) );
228 result->setSequenceNumber( rset->getInt(2) );
229 result->setNumberOfCycles( rset->getInt(3) );
230 int seq_def_id=rset->getInt(4);
232 m_run_seq.setConnection(m_env, m_conn);
233 m_run_seq.setByID(seq_def_id);
234 result->setDescription( rset->getString(5) );
238 throw(std::runtime_error(
"ODRunConfigSeqInfo::fetchData(): "+e.getMessage()));
void fetchData(ODRunConfigSeqInfo *result) noexcept(false)
void setRunSeqDef(const RunSeqDef &runSeqDef)
void writeDB() noexcept(false)
void prepareWrite() noexcept(false)
RunSeqDef getRunSeqDef() const
int fetchID() noexcept(false)
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException
int fetchIDLast() noexcept(false)
void setByID(int id) noexcept(false)