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++) {
116 m_lmfIOV = rset->getInt(1);
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)
120 m_t[
i].setToString(t.toText(
"YYYY-MM-DD HH24:MI:SS"));
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");
151 return getIOVIDsLaterThan(
t, tinf, 0);
158 return getIOVIDsLaterThan(
t, tinf, howmany);
164 return getIOVIDsLaterThan(tmin,
tmax, 0);
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;
189 if (m_conn !=
NULL) {
192 Statement *stmt = m_conn->createStatement();
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);
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;
tuple ret
prodAgent to be discontinued
std::list< int > getIOVIDsLaterThan(const Tm &t) noexcept(false)
void getParameters(ResultSet *rset)
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)
oracle::occi::SQLException SQLException
std::string fetchIdSql(Statement *stmt)
auto const T2 &decltype(t1.eta()) t2
LMFLmrSubIOV & setTimes(const Tm &t1, const Tm &t2, const Tm &t3)
oracle::occi::Statement Statement
oracle::occi::Date tmToDate(const Tm &inTm) const
static const double tmax[3]
void setToString(const std::string s) noexcept(false)
std::string writeDBSql(Statement *stmt)
LMFLmrSubIOV & setLMFIOV(const LMFIOV &iov)