8 using namespace oracle::occi;
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(
"ODJBH4Config::fetchNextId(): "+e.getMessage()));
63 throw(std::runtime_error)
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(
"ODJBH4Config::prepareWrite(): "+e.getMessage()));
85 throw(std::runtime_error)
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(
"ODJBH4Config::writeDB(): "+e.getMessage()));
111 if (!this->fetchID()) {
112 throw(std::runtime_error(
"ODJBH4Config::writeDB: Failed to write"));
119 throw(std::runtime_error)
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(rset->getString(2));
140 result->setUseBuffer( rset->getInt(3) );
141 result->setHalModuleFile( rset->getString(4) );
142 result->setHalAddressTableFile( rset->getString(5) );
143 result->setHalStaticTableFile( rset->getString(6) );
144 result->setCbd8210SerialNumber( rset->getString(7) );
145 result->setCaenBridgeType( rset->getString(8) );
146 result->setCaenLinkNumber( rset->getInt(9) );
147 result->setCaenBoardNumber( rset->getInt(10) );
150 throw(std::runtime_error(
"ODJBH4Config::fetchData(): "+e.getMessage()));
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());
174 m_ID = rset->getInt(1);
178 m_conn->terminateStatement(stmt);
180 throw(std::runtime_error(
"ODJBH4Config::fetchID: "+e.getMessage()));
void fetchData(ODJBH4Config *result)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
oracle::occi::Statement Statement
oracle::occi::ResultSet ResultSet
oracle::occi::SQLException SQLException