8 using namespace oracle::occi;
86 std::cout <<
"Run IOV ID: " << runIOVID << std::endl;
90 std::string sql =
"SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT "
92 "RUN_IOV_ID = :1 AND "
96 sql +=
"AND VMAX = :4";
98 sql +=
"ORDER BY VMAX DESC";
101 stmt->setInt(1, runIOVID);
111 std::string sql =
"SELECT RUN_IOV_ID, SEQ_NUM, SEQ_START, SEQ_STOP, "
112 "VMIN, VMAX FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT WHERE SEQ_ID = :1";
120 int runIOVID = rset->getInt(1);
121 setInt(
"seq_num", rset->getInt(2));
122 Date startDate = rset->getDate(3);
123 Date endDate = rset->getDate(4);
124 setInt(
"vmin", rset->getInt(5));
125 setInt(
"vmax", rset->getInt(6));
156 throw(std::runtime_error(
"LMFSeqDat::writeDB: not valid"));
164 throw(std::runtime_error(
"LMFSeqDat::writeDB: RunIOV not set"));
167 std::string sql =
"INSERT INTO LMF_SEQ_DAT (SEQ_ID, RUN_IOV_ID, SEQ_NUM, "
168 "SEQ_START, SEQ_STOP, VMIN, VMAX) "
169 "VALUES (SEQ_ID_" + sp +
"_SQ.NextVal, :1, :2, :3, :4, :5, :6)";
172 stmt->setInt(1, runIOVID);
182 throw(std::runtime_error)
190 throw(std::runtime_error(
"LMFSeqDat: Given RunIOV does not exist in DB"));
197 throw(std::runtime_error)
199 std::vector<std::string> pars;
200 return fetchByRunIOV(pars, sql,
method);
206 throw(std::runtime_error)
208 std::vector<std::string> pars;
209 std::stringstream
ss;
211 pars.push_back(ss.str());
212 return fetchByRunIOV(pars, sql,
method);
218 throw(std::runtime_error)
220 std::map<int, LMFSeqDat>
l;
221 this->checkConnection();
223 Statement *stmt = m_conn->createStatement();
225 for (
unsigned int i = 0;
i < pars.size();
i++) {
226 if (pars[
i][0] ==
'I') {
227 stmt->setInt(
i + 1, atoi(pars[
i].c_str() + 1));
228 }
else if (pars[
i][0] ==
'S') {
229 stmt->setString(
i + 1, pars[
i].c_str() + 1);
231 throw(std::runtime_error(m_className +
"::" +
method +
": " +
236 while (rset->next() != 0) {
237 int seq_id = rset->getInt(1);
243 m_conn->terminateStatement(stmt);
245 throw(std::runtime_error(m_className +
"::" +
method +
": " +
253 std::map<int, LMFSeqDat>
m =
254 fetchByRunIOV(
"SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT "
256 "(SELECT MAX(SEQ_ID) FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT)",
259 ret = m.begin()->second;
269 int runIOVID = iov.
getID();
271 "SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT "
272 "WHERE RUN_IOV_ID = :1",
278 int runIOVID = iov.
getID();
279 int colorId = col.
getID();
280 std::vector<std::string> pars;
281 std::stringstream
ss;
282 ss <<
"I" << runIOVID;
283 pars.push_back(ss.str());
285 ss <<
"I" << colorId;
286 pars.push_back(ss.str());
288 "SELECT S.SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT "
289 "S JOIN CMS_ECAL_LASER_COND.LMF_RUN_IOV R"
290 " ON S.SEQ_ID = R.SEQ_ID WHERE RUN_IOV_ID = :1 AND "
292 "fetchByRunIOVAndColor");
297 "SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT D "
298 "JOIN CMS_ECAL_COND.RUN_IOV R ON "
299 "D.RUN_IOV_ID = R.IOV_ID WHERE RUN_NUM = :1",
308 std::map<int, LMFSeqDat>
l;
309 std::vector<std::string> pars;
310 std::stringstream
ss;
312 pars.push_back(ss.str());
314 ss <<
"S" << taken_at;
315 pars.push_back(ss.str());
316 std::string q =
"SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT D "
317 "JOIN CMS_ECAL_COND.RUN_IOV R ON "
318 "D.RUN_IOV_ID = R.IOV_ID WHERE RUN_NUM = :1 AND "
319 "SEQ_START >= TO_DATE(:2, 'YYYY-MM-DD HH24:MI:SS') "
320 "AND SEQ_STOP <= TO_DATE(:2, 'YYYY-MM-DD HH24:MI:SS')";
324 std::map<int, LMFSeqDat>::const_iterator
x = l.begin();
326 }
else if (l.size() > 1) {
327 std::cout <<
"WARNING: Your query returned more than one result. "
329 std::cout <<
" This was not expected. Please check the DB!!!"
331 std::cout <<
"Your query: " << std::endl << q << std::endl;
332 std::cout <<
"Your parameters: " << std::endl;
333 for (
unsigned int i = 0;
i < pars.size();
i++) {
LMFUnique & setInt(std::string key, int value)
oracle::occi::Environment * m_env
std::map< int, LMFSeqDat > fetchByRunNumber(int runno)
Tm getSequenceStop() const
oracle::occi::Connection * m_conn
LMFSeqDat & setRunIOV(const RunIOV &iov)
LMFSeqDat & setSequenceStop(const Tm &end)
std::string fetchIdSql(Statement *stmt)
std::map< int, LMFSeqDat > fetchByRunIOV(RunIOV &iov)
std::string writeDBSql(Statement *stmt)
int getSequenceNumber() const
std::string sequencePostfix(const Tm &t)
oracle::occi::ResultSet ResultSet
virtual void setClassName(std::string s)
virtual void dump() const
oracle::occi::SQLException SQLException
std::map< std::string, std::string > m_stringFields
oracle::occi::Statement Statement
void setToString(const std::string s)
Tm getSequenceStart() const
oracle::occi::Date tmToDate(const Tm &inTm) const
LMFUnique & setString(std::string key, std::string value)
void getParameters(ResultSet *rset)
std::string getString(std::string fieldname) const
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Tm dateToTm(oracle::occi::Date &date) const
std::string setByIDSql(Statement *stmt, int id)
std::map< std::string, int > m_intFields