17 m_writeStmt =
nullptr;
32 this->checkConnection();
34 m_readStmt = m_conn->createStatement();
35 m_readStmt->setSQL(
"select FE_CONFIG_WEIGHT2GROUP_SQ.NextVal from DUAL ");
36 ResultSet* rset = m_readStmt->executeQuery();
37 while (rset->next()) {
41 m_conn->terminateStatement(m_readStmt);
45 throw cms::Exception(
"SQLException") <<
"FEConfigOddWeightInfo::fetchNextId(): " <<
e.getMessage();
50 this->checkConnection();
54 next_id = fetchNextId();
58 m_writeStmt = m_conn->createStatement();
59 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
60 " ( wei2_conf_id, tag, number_of_groups) " 61 " VALUES ( :1, :2, :3 ) ");
63 m_writeStmt->setInt(1, next_id);
67 throw cms::Exception(
"SQLException") <<
"FEConfigOddWeightInfo::prepareWrite(): " <<
e.getMessage();
75 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
76 if (ci->first ==
"TAG")
77 setConfigTag(ci->second);
78 if (ci->first ==
"NUMBER_OF_GROUPS")
79 setNumberOfGroups(atoi(ci->second.c_str()));
84 this->checkConnection();
89 m_writeStmt->setString(2, this->getConfigTag());
90 m_writeStmt->setInt(3, this->getNumberOfGroups());
92 m_writeStmt->executeUpdate();
95 throw cms::Exception(
"SQLException") <<
"FEConfigOddWeightInfo::writeDB(): " <<
e.getMessage();
98 if (!this->fetchID()) {
99 throw(std::runtime_error(
"FEConfigOddWeightInfo::writeDB: Failed to write"));
104 this->checkConnection();
106 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
107 throw(std::runtime_error(
"FEConfigOddWeightInfo::fetchData(): no Id defined for this FEConfigOddWeightInfo "));
113 m_readStmt->setSQL(
"SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
114 " where ( wei2_conf_id= :1 or (tag=:2 ) )");
115 m_readStmt->setInt(1,
result->getId());
116 m_readStmt->setString(2,
result->getConfigTag());
117 ResultSet* rset = m_readStmt->executeQuery();
123 result->setId(rset->getInt(1));
124 result->setConfigTag(rset->getString(2));
125 result->setNumberOfGroups(rset->getInt(3));
126 Date dbdate = rset->getDate(4);
127 result->setDBTime(
dh.dateToTm(dbdate));
130 throw cms::Exception(
"SQLException") <<
"FEConfigOddWeightInfo::fetchData(): " <<
e.getMessage();
135 this->checkConnection();
140 m_readStmt->setSQL(
"SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
141 " where wei2_conf_id = ( select max( wei2_conf_id) from " + getTable() +
" ) ");
142 ResultSet* rset = m_readStmt->executeQuery();
146 result->setId(rset->getInt(1));
147 result->setConfigTag(rset->getString(2));
148 result->setNumberOfGroups(rset->getInt(3));
149 Date dbdate = rset->getDate(4);
150 result->setDBTime(
dh.dateToTm(dbdate));
153 throw cms::Exception(
"SQLException") <<
"FEConfigOddWeightInfo::fetchData(): " <<
e.getMessage();
163 this->checkConnection();
166 Statement* stmt = m_conn->createStatement();
167 stmt->setSQL(
"SELECT wei2_conf_id FROM " + getTable() +
" WHERE tag=:1 ");
169 stmt->setString(1, getConfigTag());
171 ResultSet* rset = stmt->executeQuery();
174 m_ID = rset->getInt(1);
178 m_conn->terminateStatement(stmt);
180 throw cms::Exception(
"SQLException") <<
"FEConfigOddWeightInfo::fetchID: " <<
e.getMessage();
187 this->checkConnection();
192 Statement* stmt = m_conn->createStatement();
194 stmt->setSQL(
"SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
195 " WHERE wei2_conf_id = :1");
198 ResultSet* rset = stmt->executeQuery();
200 this->setId(rset->getInt(1));
201 this->setConfigTag(rset->getString(2));
202 this->setNumberOfGroups(rset->getInt(3));
203 Date dbdate = rset->getDate(4);
204 this->setDBTime(
dh.dateToTm(dbdate));
206 throw(std::runtime_error(
"FEConfigOddWeightInfo::setByID: Given config_id is not in the database"));
209 m_conn->terminateStatement(stmt);
211 throw cms::Exception(
"SQLException") <<
"FEConfigOddWeightInfo::setByID: " <<
e.getMessage();
~FEConfigOddWeightInfo() override
int fetchNextId() noexcept(false)
void prepareWrite() noexcept(false) override
void writeDB() noexcept(false)
void fetchData(FEConfigOddWeightInfo *result) noexcept(false)
void setByID(int id) noexcept(false)
int fetchID() noexcept(false)
oracle::occi::Statement Statement
static unsigned int getId()
void fetchLastData(FEConfigOddWeightInfo *result) noexcept(false)
oracle::occi::SQLException SQLException
void clear(HadCaloObj &c)
void setParameters(const std::map< std::string, std::string > &my_keys_map)