14 m_writeStmt =
nullptr;
45 this->checkConnection();
47 m_readStmt = m_conn->createStatement();
48 m_readStmt->setSQL(
"select ecal_JBH4_config_sq.NextVal from dual");
49 ResultSet* rset = m_readStmt->executeQuery();
50 while (rset->next ()){
51 result= rset->getInt(1);
53 m_conn->terminateStatement(m_readStmt);
57 throw(std::runtime_error(
std::string(
"ODJBH4Config::fetchNextId(): ")+getOraMessage(&e)));
65 this->checkConnection();
66 int next_id=fetchNextId();
69 m_writeStmt = m_conn->createStatement();
70 m_writeStmt->setSQL(
"INSERT INTO ECAL_Jbh4_CONFIGURATION ( jbh4_configuration_id, jbh4_tag, " 71 " useBuffer, halModuleFile, halAddressTableFile, halStaticTableFile, halcbd8210serialnumber, " 72 " caenbridgetype, caenlinknumber, caenboardnumber) " 73 " VALUES ( :1, :2, :3, :4, :5, :6, :7, :8 , :9, :10 )");
75 m_writeStmt->setInt(1, next_id);
78 throw(std::runtime_error(
std::string(
"ODJBH4Config::prepareWrite(): ")+getOraMessage(&e)));
87 this->checkConnection();
93 m_writeStmt->setString(2, this->getConfigTag());
95 m_writeStmt->setInt(3, this->getUseBuffer());
96 m_writeStmt->setString(4, this->getHalModuleFile() );
97 m_writeStmt->setString(5, this->getHalAddressTableFile() );
98 m_writeStmt->setString(6, this->getHalStaticTableFile() );
99 m_writeStmt->setString(7, this->getCbd8210SerialNumber() );
100 m_writeStmt->setString(8, this->getCaenBridgeType() );
101 m_writeStmt->setInt(9, this->getCaenLinkNumber() );
102 m_writeStmt->setInt(10, this->getCaenBoardNumber() );
104 m_writeStmt->executeUpdate();
108 throw(std::runtime_error(
std::string(
"ODJBH4Config::writeDB(): ")+getOraMessage(&e)));
111 if (!this->fetchID()) {
112 throw(std::runtime_error(
"ODJBH4Config::writeDB: Failed to write"));
121 this->checkConnection();
124 throw(std::runtime_error(
"ODJBH4Config::fetchData(): no Id defined for this ODJBH4Config "));
129 m_readStmt->setSQL(
"SELECT * FROM ECAL_Jbh4_CONFIGURATION " 130 " where ( jbh4_configuration_id = :1 or jbh4_tag=:2 )");
131 m_readStmt->setInt(1,
result->getId());
132 m_readStmt->setString(2,
result->getConfigTag());
133 ResultSet* rset = m_readStmt->executeQuery();
137 result->setId(rset->getInt(1));
138 result->setConfigTag(getOraString(rset,2));
140 result->setUseBuffer( rset->getInt(3) );
141 result->setHalModuleFile( getOraString(rset,4) );
142 result->setHalAddressTableFile( getOraString(rset,5) );
143 result->setHalStaticTableFile( getOraString(rset,6) );
144 result->setCbd8210SerialNumber( getOraString(rset,7) );
145 result->setCaenBridgeType( getOraString(rset,8) );
146 result->setCaenLinkNumber( rset->getInt(9) );
147 result->setCaenBoardNumber( rset->getInt(10) );
150 throw(std::runtime_error(
std::string(
"ODJBH4Config::fetchData(): ")+getOraMessage(&e)));
161 this->checkConnection();
164 Statement* stmt = m_conn->createStatement();
165 stmt->setSQL(
"SELECT jbh4_configuration_id FROM ecal_jbh4_configuration " 166 "WHERE jbh4_tag=:jbh4_tag ");
169 stmt->setString(1, getConfigTag());
171 ResultSet* rset = stmt->executeQuery();
174 m_ID = rset->getInt(1);
178 m_conn->terminateStatement(stmt);
180 throw(std::runtime_error(
std::string(
"ODJBH4Config::fetchID: ")+getOraMessage(&e)));
int fetchID() noexcept(false)
void fetchData(ODJBH4Config *result) noexcept(false)
void prepareWrite() noexcept(false) override
int fetchNextId() noexcept(false)
void writeDB() noexcept(false)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException