14 m_writeStmt =
nullptr;
35 this->checkConnection();
38 m_writeStmt = m_conn->createStatement();
40 "INSERT INTO ECAL_CYCLE_DAT ( sequence_id , cycle_num, tag, description ) " 41 "VALUES (:1, :2, :3 , :4 )");
44 throw(std::runtime_error(
"ODRunConfigCycleInfo::prepareWrite(): " + e.getMessage()));
49 this->checkConnection();
56 m_writeStmt->setInt(1, this->getSequenceID());
57 m_writeStmt->setInt(2, this->getCycleNumber());
58 m_writeStmt->setString(3, this->getTag());
59 m_writeStmt->setString(4, this->getDescription());
60 m_writeStmt->executeUpdate();
63 throw(std::runtime_error(
"ODRunConfigCycleInfo::writeDB: " + e.getMessage()));
66 if (!this->fetchID()) {
67 throw(std::runtime_error(
"ODRunConfigCycleInfo::writeDB: Failed to write"));
70 cout <<
"ODRunConfigCycleInfo::writeDB>> done inserting ODRunConfigCycleInfo with id=" << m_ID << endl;
79 this->checkConnection();
84 Statement* stmt = m_conn->createStatement();
86 "SELECT cycle_id from ECAL_cycle_DAT " 87 "WHERE sequence_id = :id1 " 88 " and cycle_num = :id2 ");
89 stmt->setInt(1, m_sequence_id);
90 stmt->setInt(2, m_cycle_num);
92 ResultSet* rset = stmt->executeQuery();
95 m_ID = rset->getInt(1);
99 m_conn->terminateStatement(stmt);
101 throw(std::runtime_error(
"ODRunConfigCycleInfo::fetchID: " + e.getMessage()));
109 this->checkConnection();
114 Statement* stmt = m_conn->createStatement();
115 stmt->setSQL(
"SELECT max(cycle_id) FROM ecal_cycle_dat ");
116 ResultSet* rset = stmt->executeQuery();
119 m_ID = rset->getInt(1);
123 m_conn->terminateStatement(stmt);
125 throw(std::runtime_error(
"ODRunConfigCycleInfo::fetchIDLast: " + e.getMessage()));
133 this->checkConnection();
137 cout <<
"ODRunConfigCycleInfo::setByID called for id " <<
id << endl;
140 Statement* stmt = m_conn->createStatement();
142 stmt->setSQL(
"SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 ");
145 ResultSet* rset = stmt->executeQuery();
147 m_sequence_id = rset->getInt(1);
148 m_cycle_num = rset->getInt(2);
149 m_tag = rset->getString(3);
150 m_description = rset->getString(4);
153 throw(std::runtime_error(
"ODRunConfigCycleInfo::setByID: Given cycle_id is not in the database"));
155 m_conn->terminateStatement(stmt);
157 throw(std::runtime_error(
"ODRunConfigCycleInfo::setByID: " + e.getMessage()));
162 this->checkConnection();
164 if (
result->getId() == 0) {
165 throw(std::runtime_error(
"ODRunConfigCycleInfo::fetchData(): no Id defined for this ODRunConfigCycleInfo "));
169 m_readStmt->setSQL(
"SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 ");
171 m_readStmt->setInt(1,
result->getId());
172 ResultSet* rset = m_readStmt->executeQuery();
176 result->setSequenceID(rset->getInt(1));
177 result->setCycleNumber(rset->getInt(2));
178 result->setTag(rset->getString(3));
179 result->setDescription(rset->getString(4));
182 throw(std::runtime_error(
"ODRunConfigCycleInfo::fetchData(): " + e.getMessage()));
191 terminateWriteStatement();
192 }
catch (std::runtime_error&
e) {
197 throw(std::runtime_error(
"EcalCondDBInterface::insertDataSet: Unknown exception caught"));
void writeDB() noexcept(false)
void prepareWrite() noexcept(false) override
oracle::occi::Statement Statement
int fetchIDLast() noexcept(false)
void setByID(int id) noexcept(false)
void insertConfig() noexcept(false)
void fetchData(ODRunConfigCycleInfo *result) noexcept(false)
int fetchID() noexcept(false)
oracle::occi::SQLException SQLException
~ODRunConfigCycleInfo() override