39 m_runType = runTypeDef;
52 this->checkConnection();
56 m_runType.setConnection(m_env, m_conn);
57 int run_type_id = m_runType.fetchID();
61 Statement* stmt = m_conn->createStatement();
62 stmt->setSQL(
"SELECT def_id FROM ecal_sequence_type_def WHERE " 63 " run_type_def_id = :1 and sequence_type_string = :2 " 66 stmt->setInt(1, run_type_id);
67 stmt->setString(2, m_runSeq);
69 ResultSet* rset = stmt->executeQuery();
72 m_ID = rset->getInt(1);
76 m_conn->terminateStatement(stmt);
77 }
catch (SQLException &
e) {
78 throw(std::runtime_error(
"RunSeqDef::fetchID: "+e.getMessage()));
89 this->checkConnection();
92 Statement* stmt = m_conn->createStatement();
94 stmt->setSQL(
"SELECT run_type_def_id, sequence_type_string FROM ecal_sequence_type_def WHERE def_id = :1");
98 ResultSet* rset = stmt->executeQuery();
100 idruntype = rset->getInt(1);
101 m_runSeq = rset->getString(2);
103 throw(std::runtime_error(
"RunSeqDef::setByID: Given def_id is not in the database"));
106 m_conn->terminateStatement(stmt);
108 m_runType.setConnection(m_env, m_conn);
109 m_runType.setByID(idruntype);
111 }
catch (SQLException &
e) {
112 throw(std::runtime_error(
"RunSeqDef::setByID: "+e.getMessage()));
121 this->checkConnection();
123 Statement* stmt = m_conn->createStatement();
124 stmt->setSQL(
"SELECT def_id FROM ecal_sequence_type_def ORDER BY def_id");
125 ResultSet* rset = stmt->executeQuery();
130 while(rset->next()) {
131 runSeqDef.
setByID( rset->getInt(1) );
132 fillVec->push_back( runSeqDef );
134 }
catch (SQLException &
e) {
135 throw(std::runtime_error(
"RunSeqDef::fetchAllDefs: "+e.getMessage()));
144 if (this->fetchID()) {
147 }
catch (SQLException &
e) {
152 this->checkConnection();
155 m_runType.setConnection(m_env, m_conn);
156 int run_type_id = m_runType.fetchID();
160 Statement* stmt = m_conn->createStatement();
162 stmt->setSQL(
"insert into ecal_sequence_type_def(RUN_TYPE_DEF_ID, SEQUENCE_TYPE_STRING) values " 164 stmt->setInt(1, run_type_id);
165 stmt->setString(2, m_runSeq);
168 stmt->executeUpdate();
170 m_conn->terminateStatement(stmt);
171 }
catch (SQLException &e) {
172 throw(std::runtime_error(
"RunSeqDef::writeDB: "+e.getMessage()));
176 if (!this->fetchID()) {
177 throw(std::runtime_error(
"RunSeqDef::writeDB: Failed to write"));
int fetchID() noexcept(false) override
std::string getRunSeq() const
void setByID(int id) noexcept(false) override
void fetchAllDefs(std::vector< RunSeqDef > *fillVec) noexcept(false)
RunTypeDef getRunTypeDef() const
void setRunSeq(std::string runseq)
void setRunTypeDef(const RunTypeDef &runTypeDef)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
int writeDB() noexcept(false)