24 oracle::occi::Connection* conn):
LMFUnique(env, conn)
35 << std::endl << std::flush;
64 "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV " 73 for (
int i = 0;
i < 3;
i++) {
75 stmt->setDate(i + 2, t);
83 "CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV " 84 "WHERE LMR_SUB_IOV_ID = :1";
94 for (
int i = 0;
i < 3;
i++) {
95 if (
m_t[
i].isNull()) {
101 throw(std::runtime_error(
m_className +
"::writeDB: LMFIOV not set"));
104 std::string sql =
"INSERT INTO LMF_LMR_SUB_IOV (LMR_SUB_IOV_ID, " 105 "IOV_ID, T1, T2, T3) " 106 "VALUES (LMF_LMR_SUB_IOV_ID_" + sp +
"_SQ.NextVal, :1, :2, :3, :4)";
109 for (
int i = 0;
i < 3;
i++) {
117 for (
int i = 0;
i < 3;
i++) {
118 oracle::occi::Date
t = rset->getDate(
i + 2);
119 #if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0) 123 unsigned int month = 0;
124 unsigned int day = 0;
125 unsigned int hour = 0;
126 unsigned int min = 0;
128 t.getDate(year, month, day, hour, min, seconds);
130 .tm_sec =
static_cast<int>(
seconds),
131 .tm_min = static_cast<int>(min),
132 .tm_hour =
static_cast<int>(hour),
133 .tm_mday = static_cast<int>(day),
134 .tm_mon =
static_cast<int>(month),
135 .tm_year = year - 1900
137 char tt_str[30] = { 0 };
138 if (std::strftime(tt_str,
sizeof(tt_str),
"%F %T", &
tt)) {
141 throw std::runtime_error(
"LMFLmrSubIOV::writeDBSql: failed to generate the date string");
172 std::string sql =
"SELECT * FROM (SELECT LMR_SUB_IOV_ID " 173 "FROM CMS_ECAL_LASER_COND.LMF_LMR_SUB_IOV WHERE T3 > :1 ";
175 sql +=
"AND T3 < :2 ORDER BY T3 ASC) ";
177 sql +=
"WHERE ROWNUM <= :3";
180 sql +=
"ORDER BY T3 ASC) ";
182 sql +=
"WHERE ROWNUM <= :2";
186 std::cout <<
"Executing query: " << std::endl << sql << std::endl;
193 stmt->setPrefetchRowCount(10000);
195 stmt->setDate(1, dh.
tmToDate(tmin));
199 stmt->setInt(3, howMany);
203 stmt->setInt(2, howMany);
208 while (rset->next() != 0) {
210 std::cout <<
"Getting row " << row++ << std::endl;
212 ret.push_back(rset->getInt(1));
214 stmt->setPrefetchRowCount(0);
215 m_conn->terminateStatement(stmt);
217 catch (oracle::occi::SQLException &
e) {
218 #if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0) 219 throw(std::runtime_error(
m_className +
"::getLmrSubIOVLaterThan: " +
222 throw(std::runtime_error(
m_className +
"::getLmrSubIOVLaterThan: error code " +
223 std::to_string(e.getErrorCode())));
227 throw(std::runtime_error(
m_className +
"::getLmrSubIOVLaterThan: " +
228 "Connection not set"));
235 std::cout <<
"Done!" << std::endl << std::flush;
std::list< int > getIOVIDsLaterThan(const Tm &t) noexcept(false)
oracle::occi::Environment * m_env
oracle::occi::Connection * m_conn
std::string sequencePostfix(const Tm &t)
oracle::occi::ResultSet ResultSet
std::string setByIDSql(Statement *stmt, int id) override
LMFLmrSubIOV & setTimes(const Tm &t1, const Tm &t2, const Tm &t3)
oracle::occi::Statement Statement
std::string writeDBSql(Statement *stmt) override
oracle::occi::Date tmToDate(const Tm &inTm) const
static const double tmax[3]
void setToString(const std::string s) noexcept(false)
std::string fetchIdSql(Statement *stmt) override
void getParameters(ResultSet *rset) override
LMFLmrSubIOV & setLMFIOV(const LMFIOV &iov)