33 this->checkConnection();
36 m_runType.setConnection(m_env, m_conn);
37 int run_type_id = m_runType.fetchID();
40 Statement* stmt = m_conn->createStatement();
42 "SELECT def_id FROM ecal_sequence_type_def WHERE "
43 " run_type_def_id = :1 and sequence_type_string = :2 ");
45 stmt->setInt(1, run_type_id);
46 stmt->setString(2, m_runSeq);
48 ResultSet* rset = stmt->executeQuery();
51 m_ID = rset->getInt(1);
55 m_conn->terminateStatement(stmt);
56 }
catch (SQLException&
e) {
57 throw(std::runtime_error(
"RunSeqDef::fetchID: " +
e.getMessage()));
64 this->checkConnection();
67 Statement* stmt = m_conn->createStatement();
69 stmt->setSQL(
"SELECT run_type_def_id, sequence_type_string FROM ecal_sequence_type_def WHERE def_id = :1");
73 ResultSet* rset = stmt->executeQuery();
75 idruntype = rset->getInt(1);
76 m_runSeq = rset->getString(2);
78 throw(std::runtime_error(
"RunSeqDef::setByID: Given def_id is not in the database"));
81 m_conn->terminateStatement(stmt);
83 m_runType.setConnection(m_env, m_conn);
84 m_runType.setByID(idruntype);
86 }
catch (SQLException&
e) {
87 throw(std::runtime_error(
"RunSeqDef::setByID: " +
e.getMessage()));
92 this->checkConnection();
94 Statement* stmt = m_conn->createStatement();
95 stmt->setSQL(
"SELECT def_id FROM ecal_sequence_type_def ORDER BY def_id");
96 ResultSet* rset = stmt->executeQuery();
101 while (rset->next()) {
102 runSeqDef.
setByID(rset->getInt(1));
103 fillVec->push_back(runSeqDef);
105 }
catch (SQLException&
e) {
106 throw(std::runtime_error(
"RunSeqDef::fetchAllDefs: " +
e.getMessage()));
113 if (this->fetchID()) {
116 }
catch (SQLException&
e) {
121 this->checkConnection();
124 m_runType.setConnection(m_env, m_conn);
125 int run_type_id = m_runType.fetchID();
129 Statement* stmt = m_conn->createStatement();
132 "insert into ecal_sequence_type_def(RUN_TYPE_DEF_ID, SEQUENCE_TYPE_STRING) values "
134 stmt->setInt(1, run_type_id);
135 stmt->setString(2, m_runSeq);
137 stmt->executeUpdate();
139 m_conn->terminateStatement(stmt);
140 }
catch (SQLException&
e) {
141 throw(std::runtime_error(
"RunSeqDef::writeDB: " +
e.getMessage()));
145 if (!this->fetchID()) {
146 throw(std::runtime_error(
"RunSeqDef::writeDB: Failed to write"));