8 using namespace oracle::occi;
77 std::cout <<
"Run IOV ID: " << runIOVID << std::endl;
82 "SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT "
84 "RUN_IOV_ID = :1 AND "
88 sql +=
"AND VMAX = :4";
90 sql +=
"ORDER BY VMAX DESC";
93 stmt->setInt(1, runIOVID);
104 "SELECT RUN_IOV_ID, SEQ_NUM, SEQ_START, SEQ_STOP, "
105 "VMIN, VMAX FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT WHERE SEQ_ID = :1";
113 int runIOVID = rset->getInt(1);
114 setInt(
"seq_num", rset->getInt(2));
115 Date startDate = rset->getDate(3);
116 Date endDate = rset->getDate(4);
117 setInt(
"vmin", rset->getInt(5));
118 setInt(
"vmax", rset->getInt(6));
147 throw(std::runtime_error(
"LMFSeqDat::writeDB: not valid"));
155 throw(std::runtime_error(
"LMFSeqDat::writeDB: RunIOV not set"));
159 "INSERT INTO LMF_SEQ_DAT (SEQ_ID, RUN_IOV_ID, SEQ_NUM, "
160 "SEQ_START, SEQ_STOP, VMIN, VMAX) "
162 sp +
"_SQ.NextVal, :1, :2, :3, :4, :5, :6)";
165 stmt->setInt(1, runIOVID);
181 throw(std::runtime_error(
"LMFSeqDat: Given RunIOV does not exist in DB"));
186 std::vector<std::string> pars;
187 return fetchByRunIOV(pars, sql, method);
191 std::vector<std::string> pars;
192 std::stringstream
ss;
194 pars.push_back(ss.str());
195 return fetchByRunIOV(pars, sql, method);
201 std::map<int, LMFSeqDat>
l;
202 this->checkConnection();
204 Statement *stmt = m_conn->createStatement();
206 for (
unsigned int i = 0;
i < pars.size();
i++) {
207 if (pars[
i][0] ==
'I') {
208 stmt->setInt(
i + 1, atoi(pars[
i].c_str() + 1));
209 }
else if (pars[
i][0] ==
'S') {
210 stmt->setString(
i + 1, pars[
i].c_str() + 1);
212 throw(std::runtime_error(m_className +
"::" + method +
": " +
"Invalid type"));
216 while (rset->next() != 0) {
217 int seq_id = rset->getInt(1);
223 m_conn->terminateStatement(stmt);
224 }
catch (SQLException &
e) {
225 throw(std::runtime_error(m_className +
"::" + method +
": " + e.getMessage()));
233 "SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT "
235 "(SELECT MAX(SEQ_ID) FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT)",
238 ret = m.begin()->second;
246 int runIOVID = iov.
getID();
248 "SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT "
249 "WHERE RUN_IOV_ID = :1",
254 int runIOVID = iov.
getID();
255 int colorId = col.
getID();
256 std::vector<std::string> pars;
257 std::stringstream
ss;
258 ss <<
"I" << runIOVID;
259 pars.push_back(ss.str());
261 ss <<
"I" << colorId;
262 pars.push_back(ss.str());
264 "SELECT S.SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT "
265 "S JOIN CMS_ECAL_LASER_COND.LMF_RUN_IOV R"
266 " ON S.SEQ_ID = R.SEQ_ID WHERE RUN_IOV_ID = :1 AND "
268 "fetchByRunIOVAndColor");
273 "SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT D "
274 "JOIN CMS_ECAL_COND.RUN_IOV R ON "
275 "D.RUN_IOV_ID = R.IOV_ID WHERE RUN_NUM = :1",
282 std::map<int, LMFSeqDat>
l;
283 std::vector<std::string> pars;
284 std::stringstream
ss;
286 pars.push_back(ss.str());
288 ss <<
"S" << taken_at;
289 pars.push_back(ss.str());
291 "SELECT SEQ_ID FROM CMS_ECAL_LASER_COND.LMF_SEQ_DAT D "
292 "JOIN CMS_ECAL_COND.RUN_IOV R ON "
293 "D.RUN_IOV_ID = R.IOV_ID WHERE RUN_NUM = :1 AND "
294 "SEQ_START >= TO_DATE(:2, 'YYYY-MM-DD HH24:MI:SS') "
295 "AND SEQ_STOP <= TO_DATE(:2, 'YYYY-MM-DD HH24:MI:SS')";
299 std::map<int, LMFSeqDat>::const_iterator
x = l.begin();
301 }
else if (l.size() > 1) {
302 std::cout <<
"WARNING: Your query returned more than one result. " << std::endl;
303 std::cout <<
" This was not expected. Please check the DB!!!" << std::endl;
304 std::cout <<
"Your query: " << std::endl << q << std::endl;
305 std::cout <<
"Your parameters: " << std::endl;
306 for (
unsigned int i = 0;
i < pars.size();
i++) {
void setByID(int id) noexcept(false) override
tuple ret
prodAgent to be discontinued
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)
const edm::EventSetup & c
std::map< int, LMFSeqDat > fetchByRunIOV(RunIOV &iov)
int getSequenceNumber() const
std::string sequencePostfix(const Tm &t)
oracle::occi::ResultSet ResultSet
virtual void setClassName(std::string s)
void fetchParentIDs() noexcept(false) override
virtual void dump() const
void setByID(int id) noexcept(false) override
std::string setByIDSql(Statement *stmt, int id) override
std::map< std::string, std::string > m_stringFields
bool isValid() const override
oracle::occi::Statement Statement
Tm getSequenceStart() const
oracle::occi::Date tmToDate(const Tm &inTm) const
LMFUnique & setString(std::string key, std::string value)
void getParameters(ResultSet *rset) override
void setToString(const std::string s) noexcept(false)
std::string writeDBSql(Statement *stmt) override
std::string fetchIdSql(Statement *stmt) override
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::map< std::string, int > m_intFields