15 m_writeStmt =
nullptr;
37 this->checkConnection();
39 m_readStmt = m_conn->createStatement();
40 m_readStmt->setSQL(
"select ecal_tcc_ee_config_sq.NextVal from dual");
41 ResultSet* rset = m_readStmt->executeQuery();
42 while (rset->next()) {
45 m_conn->terminateStatement(m_readStmt);
49 throw(std::runtime_error(
std::string(
"ODTCCEEConfig::fetchNextId(): ") +
e.getMessage()));
57 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
58 if (ci->first ==
"TCC_EE_CONFIGURATION_ID")
59 setConfigTag(ci->second);
60 if (ci->first ==
"N_TESTPATTERNS_TO_LOAD")
61 setNTestPatternsToLoad(atoi(ci->second.c_str()));
62 if (ci->first ==
"LUT_CONFIGURATION_FILE")
63 setLUTConfigurationFile(ci->second);
64 if (ci->first ==
"CONFIGURATION_FILE")
65 setTCCConfigurationFile(ci->second);
66 if (ci->first ==
"SLB_CONFIGURATION_FILE")
67 setSLBConfigurationFile(ci->second);
68 if (ci->first ==
"TESTPATTERNFILE_URL")
69 setTestPatternFileUrl(ci->second);
71 if (ci->first ==
"SLB_LATENCY")
72 setSLBLatency(atoi(ci->second.c_str()));
73 if (ci->first ==
"SLBLATENCY")
74 setSLBLatency(atoi(ci->second.c_str()));
76 if (ci->first ==
"TRIGGER_POS")
77 setTriggerPos(atoi(ci->second.c_str()));
82 this->checkConnection();
84 int next_id = fetchNextId();
87 m_writeStmt = m_conn->createStatement();
89 "INSERT INTO ECAL_TCC_EE_CONFIGURATION (tcc_ee_configuration_id, tcc_ee_tag, "
90 "Configuration_file, LUT_CONFIGURATION_FILE, SLB_CONFIGURATION_FILE, "
91 "TESTPATTERNFILE_URL , N_TESTPATTERNS_TO_LOAD, TRIGGER_POS, "
92 "tcc_configuration, lut_configuration, slb_configuration, slblatency ) "
93 "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10, :11, :12)");
94 m_writeStmt->setInt(1, next_id);
95 m_writeStmt->setString(2, getConfigTag());
96 m_writeStmt->setString(3, getTCCConfigurationFile());
97 m_writeStmt->setString(4, getLUTConfigurationFile());
98 m_writeStmt->setString(5, getSLBConfigurationFile());
99 m_writeStmt->setString(6, getTestPatternFileUrl());
100 m_writeStmt->setInt(7, getNTestPatternsToLoad());
101 m_writeStmt->setInt(8, getTrigPos());
102 m_writeStmt->setInt(12, getSLBLatency());
104 oracle::occi::Clob clob1(m_conn);
106 m_writeStmt->setClob(9, clob1);
108 oracle::occi::Clob clob2(m_conn);
110 m_writeStmt->setClob(10, clob2);
112 oracle::occi::Clob clob3(m_conn);
114 m_writeStmt->setClob(11, clob3);
116 m_writeStmt->executeUpdate();
119 m_conn->terminateStatement(m_writeStmt);
120 std::cout <<
"TCC 3 empty Clobs inserted into CONFIGURATION with id=" << next_id << std::endl;
123 m_writeStmt = m_conn->createStatement();
125 "SELECT tcc_configuration, lut_configuration, slb_configuration FROM ECAL_TCC_EE_CONFIGURATION WHERE"
126 " tcc_ee_configuration_id=:1 FOR UPDATE");
128 std::cout <<
"updating the clobs 0" << std::endl;
131 throw(std::runtime_error(
std::string(
"ODTCCEEConfig::prepareWrite(): ") +
e.getMessage()));
134 std::cout <<
"updating the clob 1 " << std::endl;
138 std::cout <<
"updating the clob 2" << std::endl;
141 m_writeStmt->setInt(1, m_ID);
142 ResultSet* rset = m_writeStmt->executeQuery();
144 while (rset->next()) {
145 oracle::occi::Clob clob1 = rset->getClob(1);
146 oracle::occi::Clob clob2 = rset->getClob(2);
147 oracle::occi::Clob clob3 = rset->getClob(3);
148 cout <<
"Opening the clob in read write mode" << endl;
149 cout <<
"Populating the clobs" << endl;
150 populateClob(clob1, getTCCConfigurationFile(), m_size);
151 populateClob(clob2, getLUTConfigurationFile(), m_size);
152 populateClob(clob3, getSLBConfigurationFile(), m_size);
155 m_writeStmt->executeUpdate();
156 m_writeStmt->closeResultSet(rset);
159 throw(std::runtime_error(
std::string(
"ODTCCEEConfig::writeDB(): ") +
e.getMessage()));
162 if (!this->fetchID()) {
163 throw(std::runtime_error(
"ODTCCEEConfig::writeDB: Failed to write"));
168 this->checkConnection();
170 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
171 throw(std::runtime_error(
"ODTCCEEConfig::fetchData(): no Id defined for this ODTCCEEConfig "));
177 "FROM ECAL_TCC_EE_CONFIGURATION d "
178 " where (tcc_ee_configuration_id = :1 or tcc_ee_tag=:2 )");
179 m_readStmt->setInt(1,
result->getId());
180 m_readStmt->setString(2,
result->getConfigTag());
181 ResultSet* rset = m_readStmt->executeQuery();
185 result->setId(rset->getInt(1));
186 result->setConfigTag(rset->getString(2));
188 result->setTCCConfigurationFile(rset->getString(3));
189 result->setLUTConfigurationFile(rset->getString(4));
190 result->setSLBConfigurationFile(rset->getString(5));
191 result->setTestPatternFileUrl(rset->getString(6));
192 result->setNTestPatternsToLoad(rset->getInt(7));
193 result->setSLBLatency(rset->getInt(12));
196 Clob clob1 = rset->getClob(8);
197 cout <<
"Opening the clob in Read only mode" << endl;
198 clob1.open(OCCI_LOB_READONLY);
199 int clobLength = clob1.length();
200 cout <<
"Length of the clob1 is: " << clobLength << endl;
201 unsigned char*
buffer = readClob(clob1, clobLength);
203 cout <<
"the clob buffer is:" << endl;
204 for (
int i = 0;
i < clobLength; ++
i)
209 Clob clob2 = rset->getClob(9);
210 cout <<
"Opening the clob in Read only mode" << endl;
211 clob2.open(OCCI_LOB_READONLY);
212 clobLength = clob2.length();
213 cout <<
"Length of the clob2 is: " << clobLength << endl;
214 unsigned char* buffer2 = readClob(clob2, clobLength);
216 cout <<
"the clob buffer is:" << endl;
217 for (
int i = 0;
i < clobLength; ++
i)
218 cout << (
char)buffer2[
i];
220 result->setLUTClob(buffer2);
222 Clob clob3 = rset->getClob(10);
223 cout <<
"Opening the clob in Read only mode" << endl;
224 clob3.open(OCCI_LOB_READONLY);
225 clobLength = clob3.length();
226 cout <<
"Length of the clob3 is: " << clobLength << endl;
227 unsigned char* buffer3 = readClob(clob3, clobLength);
229 cout <<
"the clob buffer is:" << endl;
230 for (
int i = 0;
i < clobLength; ++
i)
231 cout << (
char)buffer3[
i];
233 result->setSLBClob(buffer3);
236 throw(std::runtime_error(
std::string(
"ODTCCEEConfig::fetchData(): ") +
e.getMessage()));
245 this->checkConnection();
248 Statement* stmt = m_conn->createStatement();
250 "SELECT tcc_ee_configuration_id FROM ecal_tcc_ee_configuration "
251 "WHERE tcc_ee_tag=:tcc_ee_tag ");
253 stmt->setString(1, getConfigTag());
255 ResultSet* rset = stmt->executeQuery();
258 m_ID = rset->getInt(1);
262 m_conn->terminateStatement(stmt);
264 throw(std::runtime_error(
std::string(
"ODTCCEEConfig::fetchID: ") +
e.getMessage()));