15 m_writeStmt =
nullptr;
30 this->checkConnection();
31 std::cout <<
"going to fetch new id for TTCF 1" << endl;
32 m_readStmt = m_conn->createStatement();
33 m_readStmt->setSQL(
"select ecal_ttcf_config_sq.NextVal from dual");
34 ResultSet* rset = m_readStmt->executeQuery();
35 while (rset->next()) {
40 m_conn->terminateStatement(m_readStmt);
44 throw(std::runtime_error(
std::string(
"ODTTCFConfig::fetchNextId(): ") +
e.getMessage()));
49 this->checkConnection();
50 int next_id = fetchNextId();
53 m_writeStmt = m_conn->createStatement();
55 "INSERT INTO ECAL_TTCF_CONFIGURATION (ttcf_configuration_id, ttcf_tag, " 56 " rxbc0_delay, reg_30 , ttcf_configuration_file , ttcf_configuration ) " 57 "VALUES (:1, :2, :3 , :4, :5, :6)");
58 m_writeStmt->setInt(1, next_id);
59 m_writeStmt->setString(2, getConfigTag());
61 m_writeStmt->setInt(3, getRxBC0Delay());
62 m_writeStmt->setInt(4, getReg30());
64 m_writeStmt->setString(5, getTTCFConfigurationFile());
66 oracle::occi::Clob clob(m_conn);
68 m_writeStmt->setClob(6, clob);
69 m_writeStmt->executeUpdate();
72 m_conn->terminateStatement(m_writeStmt);
73 std::cout <<
"inserted into CONFIGURATION with id=" << next_id << std::endl;
76 m_writeStmt = m_conn->createStatement();
78 "SELECT ttcf_configuration FROM ECAL_TTCF_CONFIGURATION WHERE" 79 " ttcf_configuration_id=:1 FOR UPDATE");
81 std::cout <<
"updating the clob 0" << std::endl;
84 throw(std::runtime_error(
std::string(
"ODTTCFConfig::prepareWrite(): ") +
e.getMessage()));
87 std::cout <<
"updating the clob 1 " << std::endl;
91 std::cout <<
"updating the clob 2" << std::endl;
94 m_writeStmt->setInt(1, m_ID);
95 ResultSet* rset = m_writeStmt->executeQuery();
99 oracle::occi::Clob clob = rset->getClob(1);
100 cout <<
"Opening the clob in read write mode" << endl;
101 populateClob(clob, getTTCFConfigurationFile(), m_size);
102 int clobLength = clob.length();
103 cout <<
"Length of the clob is: " << clobLength << endl;
105 m_writeStmt->executeUpdate();
106 m_writeStmt->closeResultSet(rset);
109 throw(std::runtime_error(
std::string(
"ODTTCFConfig::writeDB(): ") +
e.getMessage()));
112 if (!this->fetchID()) {
113 throw(std::runtime_error(
"ODTTCFConfig::writeDB: Failed to write"));
118 this->checkConnection();
121 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
122 throw(std::runtime_error(
"ODTTCFConfig::fetchData(): no Id defined for this ODTTCFConfig "));
128 "FROM ECAL_TTCF_CONFIGURATION " 129 " where (ttcf_configuration_id = :1 or ttcf_tag= :2) ");
130 m_readStmt->setInt(1,
result->getId());
131 m_readStmt->setString(2,
result->getConfigTag());
132 ResultSet* rset = m_readStmt->executeQuery();
136 result->setId(rset->getInt(1));
137 result->setConfigTag(rset->getString(2));
138 result->setTTCFConfigurationFile(rset->getString(3));
139 Clob clob = rset->getClob(4);
140 cout <<
"Opening the clob in Read only mode" << endl;
141 clob.open(OCCI_LOB_READONLY);
142 int clobLength = clob.length();
143 cout <<
"Length of the clob is: " << clobLength << endl;
145 unsigned char*
buffer = readClob(clob, m_size);
150 throw(std::runtime_error(
std::string(
"ODTTCFConfig::fetchData(): ") +
e.getMessage()));
159 this->checkConnection();
162 Statement* stmt = m_conn->createStatement();
164 "SELECT ttcf_configuration_id FROM ecal_ttcf_configuration " 165 "WHERE ttcf_tag=:ttcf_tag ");
167 stmt->setString(1, getConfigTag());
169 ResultSet* rset = stmt->executeQuery();
172 m_ID = rset->getInt(1);
176 m_conn->terminateStatement(stmt);
178 throw(std::runtime_error(
std::string(
"ODTTCFConfig::fetchID: ") +
e.getMessage()));
188 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
189 if (ci->first ==
"TTCF_CONFIGURATION_ID")
190 setConfigTag(ci->second);
191 if (ci->first ==
"Configuration") {
200 cout <<
"fname=" <<
fname <<
" and reduced is: " << str3 << endl;
201 setTTCFConfigurationFile(str3);
204 std::cout <<
"Going to read file: " << str3 << endl;
207 inpFile.open(str3.c_str());
212 bufsize = inpFile.tellg();
213 std::cout <<
" bufsize =" << bufsize << std::endl;
215 inpFile.seekg(0, ios::beg);
220 }
else if (ci->first ==
"RXBC0_DELAY") {
221 setRxBC0Delay(atoi(ci->second.c_str()));
222 }
else if (ci->first ==
"REG_30") {
223 setReg30(atoi(ci->second.c_str()));
void prepareWrite() noexcept(false) override
oracle::occi::Statement Statement
void setParameters(const std::map< std::string, std::string > &my_keys_map)
int fetchID() noexcept(false)
oracle::occi::SQLException SQLException
void clear(HadCaloObj &c)
int fetchNextId() noexcept(false)
void writeDB() noexcept(false)
void fetchData(ODTTCFConfig *result) noexcept(false)