27 std::cout <<
"[LMFLmrSubIOV] Setting IOV_ID as " << iov.
getID() << std::endl << std::flush;
56 "SELECT LMR_SUB_IOV_ID FROM "
57 "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV "
66 for (
int i = 0;
i < 3;
i++) {
67 oracle::occi::Date
t =
dh.tmToDate(
m_t[
i]);
68 stmt->setDate(
i + 2,
t);
75 "SELECT IOV_ID, T1, T2, T3 FROM "
76 "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV "
77 "WHERE LMR_SUB_IOV_ID = :1";
87 for (
int i = 0;
i < 3;
i++) {
88 if (
m_t[
i].isNull()) {
89 m_t[
i] =
dh.getPlusInfTm();
94 throw(std::runtime_error(
m_className +
"::writeDB: LMFIOV not set"));
98 "INSERT INTO LMF_LMR_SUB_IOV (LMR_SUB_IOV_ID, "
99 "IOV_ID, T1, T2, T3) "
100 "VALUES (LMF_LMR_SUB_IOV_ID_" +
101 sp +
"_SQ.NextVal, :1, :2, :3, :4)";
104 for (
int i = 0;
i < 3;
i++) {
105 stmt->setDate(
i + 2,
dh.tmToDate(
m_t[
i]));
111 m_lmfIOV = rset->getInt(1);
112 for (
int i = 0;
i < 3;
i++) {
113 oracle::occi::Date
t = rset->getDate(
i + 2);
114 #if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0)
115 m_t[
i].setToString(
t.toText(
"YYYY-MM-DD HH24:MI:SS"));
118 unsigned int month = 0;
119 unsigned int day = 0;
120 unsigned int hour = 0;
121 unsigned int min = 0;
124 const std::tm
tt = {.tm_sec = static_cast<int>(
seconds),
125 .tm_min = static_cast<int>(
min),
126 .tm_hour = static_cast<int>(hour),
127 .tm_mday = static_cast<int>(
day),
128 .tm_mon = static_cast<int>(month),
129 .tm_year = year - 1900,
135 char tt_str[30] = {0};
136 if (std::strftime(tt_str,
sizeof(tt_str),
"%F %T", &
tt)) {
139 throw std::runtime_error(
"LMFLmrSubIOV::writeDBSql: failed to generate the date string");
148 return getIOVIDsLaterThan(
t, tinf, 0);
154 return getIOVIDsLaterThan(
t, tinf, howmany);
158 return getIOVIDsLaterThan(
tmin,
tmax, 0);
165 "SELECT * FROM (SELECT LMR_SUB_IOV_ID "
166 "FROM CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV WHERE T3 > :1 ";
168 sql +=
"AND T3 < :2 ORDER BY T3 ASC) ";
170 sql +=
"WHERE ROWNUM <= :3";
173 sql +=
"ORDER BY T3 ASC) ";
175 sql +=
"WHERE ROWNUM <= :2";
179 std::cout <<
"Executing query: " << std::endl << sql << std::endl;
182 if (m_conn !=
nullptr) {
185 Statement *stmt = m_conn->createStatement();
186 stmt->setPrefetchRowCount(10000);
188 stmt->setDate(1,
dh.tmToDate(
tmin));
190 stmt->setDate(2,
dh.tmToDate(
tmax));
192 stmt->setInt(3, howMany);
196 stmt->setInt(2, howMany);
201 while (rset->next() != 0) {
203 std::cout <<
"Getting row " << row++ << std::endl;
205 ret.push_back(rset->getInt(1));
207 stmt->setPrefetchRowCount(0);
208 m_conn->terminateStatement(stmt);
209 }
catch (oracle::occi::SQLException &
e) {
210 #if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0)
211 throw(std::runtime_error(m_className +
"::getLmrSubIOVLaterThan: " +
e.getMessage()));
214 std::runtime_error(m_className +
"::getLmrSubIOVLaterThan: error code " + std::to_string(
e.getErrorCode())));
218 throw(std::runtime_error(m_className +
"::getLmrSubIOVLaterThan: " +
"Connection not set"));
225 std::cout <<
"Done!" << std::endl << std::flush;