16 m_writeStmt =
nullptr;
31 this->checkConnection();
33 m_readStmt = m_conn->createStatement();
34 m_readStmt->setSQL(
"select FE_CONFIG_WEIGHT2GROUP_SQ.NextVal from DUAL ");
35 ResultSet* rset = m_readStmt->executeQuery();
36 while (rset->next()) {
40 m_conn->terminateStatement(m_readStmt);
44 throw(std::runtime_error(
std::string(
"FEConfigOddWeightInfo::fetchNextId(): ") +
e.getMessage()));
49 this->checkConnection();
53 next_id = fetchNextId();
57 m_writeStmt = m_conn->createStatement();
58 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
59 " ( wei2_conf_id, tag, number_of_groups) "
60 " VALUES ( :1, :2, :3 ) ");
62 m_writeStmt->setInt(1, next_id);
66 throw(std::runtime_error(
std::string(
"FEConfigOddWeightInfo::prepareWrite(): ") +
e.getMessage()));
74 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
75 if (ci->first ==
"TAG")
76 setConfigTag(ci->second);
77 if (ci->first ==
"NUMBER_OF_GROUPS")
78 setNumberOfGroups(atoi(ci->second.c_str()));
83 this->checkConnection();
88 m_writeStmt->setString(2, this->getConfigTag());
89 m_writeStmt->setInt(3, this->getNumberOfGroups());
91 m_writeStmt->executeUpdate();
94 throw(std::runtime_error(
std::string(
"FEConfigOddWeightInfo::writeDB(): ") +
e.getMessage()));
97 if (!this->fetchID()) {
98 throw(std::runtime_error(
"FEConfigOddWeightInfo::writeDB: Failed to write"));
103 this->checkConnection();
105 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
106 throw(std::runtime_error(
"FEConfigOddWeightInfo::fetchData(): no Id defined for this FEConfigOddWeightInfo "));
112 m_readStmt->setSQL(
"SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
113 " where ( wei2_conf_id= :1 or (tag=:2 ) )");
114 m_readStmt->setInt(1,
result->getId());
115 m_readStmt->setString(2,
result->getConfigTag());
116 ResultSet* rset = m_readStmt->executeQuery();
122 result->setId(rset->getInt(1));
123 result->setConfigTag(rset->getString(2));
124 result->setNumberOfGroups(rset->getInt(3));
125 Date dbdate = rset->getDate(4);
126 result->setDBTime(
dh.dateToTm(dbdate));
129 throw(std::runtime_error(
std::string(
"FEConfigOddWeightInfo::fetchData(): ") +
e.getMessage()));
134 this->checkConnection();
139 m_readStmt->setSQL(
"SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
140 " where wei2_conf_id = ( select max( wei2_conf_id) from " + getTable() +
" ) ");
141 ResultSet* rset = m_readStmt->executeQuery();
145 result->setId(rset->getInt(1));
146 result->setConfigTag(rset->getString(2));
147 result->setNumberOfGroups(rset->getInt(3));
148 Date dbdate = rset->getDate(4);
149 result->setDBTime(
dh.dateToTm(dbdate));
152 throw(std::runtime_error(
std::string(
"FEConfigOddWeightInfo::fetchData(): ") +
e.getMessage()));
162 this->checkConnection();
165 Statement* stmt = m_conn->createStatement();
166 stmt->setSQL(
"SELECT wei2_conf_id FROM " + getTable() +
" WHERE tag=:1 ");
168 stmt->setString(1, getConfigTag());
170 ResultSet* rset = stmt->executeQuery();
173 m_ID = rset->getInt(1);
177 m_conn->terminateStatement(stmt);
179 throw(std::runtime_error(
std::string(
"FEConfigOddWeightInfo::fetchID: ") +
e.getMessage()));
186 this->checkConnection();
191 Statement* stmt = m_conn->createStatement();
193 stmt->setSQL(
"SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
194 " WHERE wei2_conf_id = :1");
197 ResultSet* rset = stmt->executeQuery();
199 this->setId(rset->getInt(1));
200 this->setConfigTag(rset->getString(2));
201 this->setNumberOfGroups(rset->getInt(3));
202 Date dbdate = rset->getDate(4);
203 this->setDBTime(
dh.dateToTm(dbdate));
205 throw(std::runtime_error(
"FEConfigOddWeightInfo::setByID: Given config_id is not in the database"));
208 m_conn->terminateStatement(stmt);
210 throw(std::runtime_error(
std::string(
"FEConfigOddWeightInfo::setByID: ") +
e.getMessage()));