17 m_writeStmt =
nullptr;
32 this->checkConnection();
34 m_readStmt = m_conn->createStatement();
35 m_readStmt->setSQL(
"select FE_CONFIG_COKE_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") <<
"FEConfigCokeInfo::fetchNextId(): " <<
e.getMessage();
50 this->checkConnection();
54 next_id = fetchNextId();
58 m_writeStmt = m_conn->createStatement();
59 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
60 " ( coke_conf_id, tag, version) " 61 " VALUES ( :1, :2, :3 ) ");
63 m_writeStmt->setInt(1, next_id);
67 throw cms::Exception(
"SQLException") <<
"FEConfigCokeInfo::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 ==
"VERSION")
77 setVersion(atoi(ci->second.c_str()));
78 if (ci->first ==
"TAG")
79 setConfigTag(ci->second);
84 this->checkConnection();
89 m_writeStmt->setString(2, this->getConfigTag());
90 m_writeStmt->setInt(3, this->getVersion());
92 m_writeStmt->executeUpdate();
95 throw cms::Exception(
"SQLException") <<
"FEConfigCokeInfo::writeDB(): " <<
e.getMessage();
98 if (!this->fetchID()) {
99 throw(std::runtime_error(
"FEConfigCokeInfo::writeDB: Failed to write"));
104 this->checkConnection();
106 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
107 throw(std::runtime_error(
"FEConfigCokeInfo::fetchData(): no Id defined for this FEConfigCokeInfo "));
113 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where ( coke_conf_id= :1 or (tag=:2 AND version=:3 ) )");
114 m_readStmt->setInt(1,
result->getId());
115 m_readStmt->setString(2,
result->getConfigTag());
116 m_readStmt->setInt(3,
result->getVersion());
117 ResultSet* rset = m_readStmt->executeQuery();
123 result->setId(rset->getInt(1));
124 result->setConfigTag(rset->getString(2));
125 result->setVersion(rset->getInt(3));
127 Date dbdate = rset->getDate(4);
128 result->setDBTime(
dh.dateToTm(dbdate));
131 throw cms::Exception(
"SQLException") <<
"FEConfigCokeInfo::fetchData(): " <<
e.getMessage();
136 this->checkConnection();
141 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where coke_conf_id = ( select max( coke_conf_id) from " +
143 ResultSet* rset = m_readStmt->executeQuery();
147 result->setId(rset->getInt(1));
148 result->setConfigTag(rset->getString(2));
149 result->setVersion(rset->getInt(3));
150 Date dbdate = rset->getDate(4);
151 result->setDBTime(
dh.dateToTm(dbdate));
154 throw cms::Exception(
"SQLException") <<
"FEConfigCokeInfo::fetchData(): " <<
e.getMessage();
164 this->checkConnection();
167 Statement* stmt = m_conn->createStatement();
168 stmt->setSQL(
"SELECT coke_conf_id FROM " + getTable() +
" WHERE tag=:1 and version=:2 ");
170 stmt->setString(1, getConfigTag());
171 stmt->setInt(2, getVersion());
173 ResultSet* rset = stmt->executeQuery();
176 m_ID = rset->getInt(1);
180 m_conn->terminateStatement(stmt);
182 throw cms::Exception(
"SQLException") <<
"FEConfigCokeInfo::fetchID: " <<
e.getMessage();
189 this->checkConnection();
194 Statement* stmt = m_conn->createStatement();
196 stmt->setSQL(
"SELECT * FROM " + getTable() +
" WHERE coke_conf_id = :1");
199 ResultSet* rset = stmt->executeQuery();
201 this->setId(rset->getInt(1));
202 this->setConfigTag(rset->getString(2));
203 this->setVersion(rset->getInt(3));
205 Date dbdate = rset->getDate(4);
206 this->setDBTime(
dh.dateToTm(dbdate));
208 throw(std::runtime_error(
"FEConfigCokeInfo::setByID: Given config_id is not in the database"));
211 m_conn->terminateStatement(stmt);
213 throw cms::Exception(
"SQLException") <<
"FEConfigCokeInfo::setByID: " <<
e.getMessage();
void setByID(int id) noexcept(false)
int fetchID() noexcept(false)
int fetchNextId() noexcept(false)
~FEConfigCokeInfo() override
void prepareWrite() noexcept(false) override
oracle::occi::Statement Statement
void setParameters(const std::map< std::string, std::string > &my_keys_map)
static unsigned int getId()
oracle::occi::SQLException SQLException
void clear(HadCaloObj &c)
void fetchLastData(FEConfigCokeInfo *result) noexcept(false)
void fetchData(FEConfigCokeInfo *result) noexcept(false)
void writeDB() noexcept(false)