7 using namespace oracle::occi;
39 m_runType = runTypeDef;
45 throw(std::runtime_error)
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);
72 m_ID = rset->getInt(1);
76 m_conn->terminateStatement(stmt);
78 throw(std::runtime_error(
"RunSeqDef::fetchID: "+e.getMessage()));
87 throw(std::runtime_error)
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");
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);
112 throw(std::runtime_error(
"RunSeqDef::setByID: "+e.getMessage()));
119 throw(std::runtime_error)
121 this->checkConnection();
123 Statement* stmt = m_conn->createStatement();
124 stmt->setSQL(
"SELECT def_id FROM ecal_sequence_type_def ORDER BY def_id");
130 while(rset->next()) {
131 runSeqDef.
setByID( rset->getInt(1) );
132 fillVec->push_back( runSeqDef );
135 throw(std::runtime_error(
"RunSeqDef::fetchAllDefs: "+e.getMessage()));
140 throw(std::runtime_error)
144 if (this->fetchID()) {
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);
172 throw(std::runtime_error(
"RunSeqDef::writeDB: "+e.getMessage()));
176 if (!this->fetchID()) {
177 throw(std::runtime_error(
"RunSeqDef::writeDB: Failed to write"));
oracle::occi::SQLException SQLException
std::string getRunSeq() const
RunTypeDef getRunTypeDef() const
void setRunSeq(std::string runseq)
oracle::occi::ResultSet ResultSet
void setRunTypeDef(const RunTypeDef &runTypeDef)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
void fetchAllDefs(std::vector< RunSeqDef > *fillVec)