10 using namespace oracle::occi;
43 this->checkConnection();
45 m_readStmt = m_conn->createStatement();
46 m_readStmt->setSQL(
"select ecal_tcc_ee_config_sq.NextVal from dual");
47 ResultSet* rset = m_readStmt->executeQuery();
48 while (rset->next ()){
49 result= rset->getInt(1);
51 m_conn->terminateStatement(m_readStmt);
55 throw(std::runtime_error(
"ODTCCEEConfig::fetchNextId(): "+e.getMessage()));
66 for( std::map<std::string, std::string >::iterator ci=
67 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
69 if(ci->first==
"TCC_EE_CONFIGURATION_ID") setConfigTag(ci->second);
70 if(ci->first==
"N_TESTPATTERNS_TO_LOAD") setNTestPatternsToLoad(atoi(ci->second.c_str()));
71 if(ci->first==
"LUT_CONFIGURATION_FILE") setLUTConfigurationFile(ci->second );
72 if(ci->first==
"CONFIGURATION_FILE") setTCCConfigurationFile(ci->second );
73 if(ci->first==
"SLB_CONFIGURATION_FILE") setSLBConfigurationFile(ci->second );
74 if(ci->first==
"TESTPATTERNFILE_URL") setTestPatternFileUrl(ci->second );
76 if(ci->first==
"SLB_LATENCY") setSLBLatency(atoi(ci->second.c_str()) );
77 if(ci->first==
"SLBLATENCY") setSLBLatency(atoi(ci->second.c_str()) );
79 if(ci->first==
"TRIGGER_POS") setTriggerPos(atoi(ci->second.c_str()));
88 throw(std::runtime_error)
90 this->checkConnection();
92 int next_id=fetchNextId();
95 m_writeStmt = m_conn->createStatement();
96 m_writeStmt->setSQL(
"INSERT INTO ECAL_TCC_EE_CONFIGURATION (tcc_ee_configuration_id, tcc_ee_tag, "
97 "Configuration_file, LUT_CONFIGURATION_FILE, SLB_CONFIGURATION_FILE, "
98 "TESTPATTERNFILE_URL , N_TESTPATTERNS_TO_LOAD, TRIGGER_POS, "
99 "tcc_configuration, lut_configuration, slb_configuration, slblatency ) "
100 "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10, :11, :12)");
101 m_writeStmt->setInt(1, next_id);
102 m_writeStmt->setString(2, getConfigTag());
103 m_writeStmt->setString(3, getTCCConfigurationFile());
104 m_writeStmt->setString(4, getLUTConfigurationFile());
105 m_writeStmt->setString(5, getSLBConfigurationFile());
106 m_writeStmt->setString(6, getTestPatternFileUrl());
107 m_writeStmt->setInt(7, getNTestPatternsToLoad());
108 m_writeStmt->setInt(8, getTrigPos());
109 m_writeStmt->setInt(12, getSLBLatency());
111 oracle::occi::Clob clob1(m_conn);
113 m_writeStmt->setClob(9,clob1);
115 oracle::occi::Clob clob2(m_conn);
117 m_writeStmt->setClob(10,clob2);
119 oracle::occi::Clob clob3(m_conn);
121 m_writeStmt->setClob(11,clob3);
123 m_writeStmt->executeUpdate ();
126 m_conn->terminateStatement(m_writeStmt);
127 std::cout<<
"TCC 3 empty Clobs inserted into CONFIGURATION with id="<<next_id<<std::endl;
130 m_writeStmt = m_conn->createStatement();
131 m_writeStmt->setSQL (
"SELECT tcc_configuration, lut_configuration, slb_configuration FROM ECAL_TCC_EE_CONFIGURATION WHERE"
132 " tcc_ee_configuration_id=:1 FOR UPDATE");
134 std::cout<<
"updating the clobs 0"<<std::endl;
138 throw(std::runtime_error(
"ODTCCEEConfig::prepareWrite(): "+e.getMessage()));
141 std::cout<<
"updating the clob 1 "<<std::endl;
146 throw(std::runtime_error)
149 std::cout<<
"updating the clob 2"<<std::endl;
153 m_writeStmt->setInt(1, m_ID);
154 ResultSet* rset = m_writeStmt->executeQuery();
156 while (rset->next ())
158 oracle::occi::Clob clob1 = rset->getClob (1);
159 oracle::occi::Clob clob2 = rset->getClob (2);
160 oracle::occi::Clob clob3 = rset->getClob (3);
161 cout <<
"Opening the clob in read write mode" << endl;
162 cout <<
"Populating the clobs" << endl;
163 populateClob (clob1, getTCCConfigurationFile(), m_size);
164 populateClob (clob2, getLUTConfigurationFile(), m_size);
165 populateClob (clob3, getSLBConfigurationFile(), m_size);
169 m_writeStmt->executeUpdate();
170 m_writeStmt->closeResultSet (rset);
173 throw(std::runtime_error(
"ODTCCEEConfig::writeDB(): "+e.getMessage()));
176 if (!this->fetchID()) {
177 throw(std::runtime_error(
"ODTCCEEConfig::writeDB: Failed to write"));
189 throw(std::runtime_error)
191 this->checkConnection();
193 if(
result->getId()==0 && (
result->getConfigTag()==
"") ){
194 throw(std::runtime_error(
"ODTCCEEConfig::fetchData(): no Id defined for this ODTCCEEConfig "));
199 m_readStmt->setSQL(
"SELECT * "
200 "FROM ECAL_TCC_EE_CONFIGURATION d "
201 " where (tcc_ee_configuration_id = :1 or tcc_ee_tag=:2 )" );
202 m_readStmt->setInt(1,
result->getId());
203 m_readStmt->setString(2,
result->getConfigTag());
204 ResultSet* rset = m_readStmt->executeQuery();
208 result->setId(rset->getInt(1));
209 result->setConfigTag(rset->getString(2));
211 result->setTCCConfigurationFile(rset->getString(3));
212 result->setLUTConfigurationFile(rset->getString(4));
213 result->setSLBConfigurationFile(rset->getString(5));
214 result->setTestPatternFileUrl(rset->getString(6));
215 result->setNTestPatternsToLoad(rset->getInt(7));
216 result->setSLBLatency(rset->getInt(12));
219 Clob clob1 = rset->getClob (8);
220 cout <<
"Opening the clob in Read only mode" << endl;
221 clob1.open (OCCI_LOB_READONLY);
222 int clobLength=clob1.length ();
223 cout <<
"Length of the clob1 is: " << clobLength << endl;
224 unsigned char* buffer = readClob (clob1, clobLength);
226 cout<<
"the clob buffer is:"<<endl;
227 for (
int i = 0;
i < clobLength; ++
i)
228 cout << (
char) buffer[
i];
230 result->setTCCClob(buffer );
232 Clob clob2 = rset->getClob (9);
233 cout <<
"Opening the clob in Read only mode" << endl;
234 clob2.open (OCCI_LOB_READONLY);
235 clobLength=clob2.length ();
236 cout <<
"Length of the clob2 is: " << clobLength << endl;
237 unsigned char* buffer2 = readClob (clob2, clobLength);
239 cout<<
"the clob buffer is:"<<endl;
240 for (
int i = 0;
i < clobLength; ++
i)
241 cout << (
char) buffer2[
i];
243 result->setLUTClob(buffer2 );
245 Clob clob3 = rset->getClob (10);
246 cout <<
"Opening the clob in Read only mode" << endl;
247 clob3.open (OCCI_LOB_READONLY);
248 clobLength=clob3.length ();
249 cout <<
"Length of the clob3 is: " << clobLength << endl;
250 unsigned char* buffer3 = readClob (clob3, clobLength);
252 cout<<
"the clob buffer is:"<<endl;
253 for (
int i = 0;
i < clobLength; ++
i)
254 cout << (
char) buffer3[
i];
256 result->setSLBClob(buffer3 );
259 throw(std::runtime_error(
"ODTCCEEConfig::fetchData(): "+e.getMessage()));
271 this->checkConnection();
274 Statement* stmt = m_conn->createStatement();
275 stmt->setSQL(
"SELECT tcc_ee_configuration_id FROM ecal_tcc_ee_configuration "
276 "WHERE tcc_ee_tag=:tcc_ee_tag "
279 stmt->setString(1, getConfigTag() );
284 m_ID = rset->getInt(1);
288 m_conn->terminateStatement(stmt);
290 throw(std::runtime_error(
"ODTCCEEConfig::fetchID: "+e.getMessage()));
oracle::occi::Statement Statement
oracle::occi::ResultSet ResultSet
oracle::occi::SQLException SQLException
void setParameters(std::map< std::string, std::string > my_keys_map)
void fetchData(ODTCCEEConfig *result)