16 m_writeStmt =
nullptr;
32 this->checkConnection();
34 m_readStmt = m_conn->createStatement();
35 m_readStmt->setSQL(
"select ecal_ltc_config_sq.NextVal from dual");
36 ResultSet* rset = m_readStmt->executeQuery();
37 while (rset->next()) {
40 m_conn->terminateStatement(m_readStmt);
44 throw(std::runtime_error(
std::string(
"ODLTCConfig::fetchNextId(): ") +
e.getMessage()));
49 this->checkConnection();
51 int next_id = fetchNextId();
54 m_writeStmt = m_conn->createStatement();
56 "INSERT INTO ECAL_LTC_CONFIGURATION (ltc_configuration_id, ltc_tag, "
57 " LTC_CONFIGURATION_file, "
59 "VALUES (:1, :2, :3, :4 )");
60 m_writeStmt->setInt(1, next_id);
61 m_writeStmt->setString(2, this->getConfigTag());
62 m_writeStmt->setString(3, getLTCConfigurationFile());
65 oracle::occi::Clob clob(m_conn);
67 m_writeStmt->setClob(4, clob);
68 m_writeStmt->executeUpdate();
71 m_conn->terminateStatement(m_writeStmt);
72 std::cout <<
"LTC Clob inserted into CONFIGURATION with id=" << next_id << std::endl;
75 m_writeStmt = m_conn->createStatement();
77 "SELECT Configuration FROM ECAL_LTC_CONFIGURATION WHERE"
78 " ltc_configuration_id=:1 FOR UPDATE");
80 std::cout <<
"updating the clob 0" << std::endl;
83 throw(std::runtime_error(
std::string(
"ODLTCConfig::prepareWrite(): ") +
e.getMessage()));
86 std::cout <<
"updating the clob 1 " << std::endl;
93 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
94 if (ci->first ==
"LTC_CONFIGURATION_ID")
95 setConfigTag(ci->second);
96 if (ci->first ==
"Configuration") {
105 cout <<
"fname=" <<
fname <<
" and reduced is: " << str3 << endl;
106 setLTCConfigurationFile(str3);
112 inpFile.open(str3.c_str());
117 bufsize = inpFile.tellg();
118 std::cout <<
" bufsize =" << bufsize << std::endl;
120 inpFile.seekg(0, ios::beg);
130 std::cout <<
"updating the clob " << std::endl;
133 m_writeStmt->setInt(1, m_ID);
134 ResultSet* rset = m_writeStmt->executeQuery();
137 oracle::occi::Clob clob = rset->getClob(1);
139 cout <<
"Opening the clob in read write mode" << endl;
141 std::cout <<
"Populating the clob" << endl;
143 populateClob(clob, getLTCConfigurationFile(), m_size);
144 int clobLength = clob.length();
145 cout <<
"Length of the clob is: " << clobLength << endl;
148 m_writeStmt->executeUpdate();
150 m_writeStmt->closeResultSet(rset);
153 throw(std::runtime_error(
std::string(
"ODLTCConfig::writeDB(): ") +
e.getMessage()));
156 if (!this->fetchID()) {
157 throw(std::runtime_error(
"ODLTCConfig::writeDB: Failed to write"));
168 this->checkConnection();
170 if (
result->getId() == 0 &&
result->getConfigTag().empty()) {
171 throw(std::runtime_error(
"ODLTCConfig::fetchData(): no Id defined for this ODLTCConfig "));
177 "FROM ECAL_LTC_CONFIGURATION "
178 " where (ltc_configuration_id = :1 or LTC_tag=:2 )");
179 m_readStmt->setInt(1,
result->getId());
180 m_readStmt->setString(2,
result->getConfigTag());
181 ResultSet* rset = m_readStmt->executeQuery();
186 result->setId(rset->getInt(1));
187 result->setConfigTag(rset->getString(2));
188 result->setLTCConfigurationFile(rset->getString(3));
190 Clob clob = rset->getClob(4);
191 cout <<
"Opening the clob in Read only mode" << endl;
192 clob.open(OCCI_LOB_READONLY);
193 int clobLength = clob.length();
194 cout <<
"Length of the clob is: " << clobLength << endl;
196 unsigned char*
buffer = readClob(clob, clobLength);
198 cout <<
"the clob buffer is:" << endl;
199 for (
int i = 0;
i < clobLength; ++
i)
206 throw(std::runtime_error(
std::string(
"ODLTCConfig::fetchData(): ") +
e.getMessage()));
215 this->checkConnection();
218 Statement* stmt = m_conn->createStatement();
220 "SELECT ltc_configuration_id FROM ecal_ltc_configuration "
221 "WHERE ltc_tag=:ltc_tag ");
223 stmt->setString(1, getConfigTag());
225 ResultSet* rset = stmt->executeQuery();
228 m_ID = rset->getInt(1);
232 m_conn->terminateStatement(stmt);
234 throw(std::runtime_error(
std::string(
"ODLTCConfig::fetchID: ") +
e.getMessage()));