14 m_writeStmt =
nullptr;
29 this->checkConnection();
31 m_readStmt = m_conn->createStatement();
32 m_readStmt->setSQL(
"select COND2CONF_INFO_SQ.NextVal from DUAL ");
33 ResultSet* rset = m_readStmt->executeQuery();
34 while (rset->next()) {
38 m_conn->terminateStatement(m_readStmt);
42 throw(std::runtime_error(
std::string(
"ODVfeToRejectInfo::fetchNextId(): ") +
e.getMessage()));
47 this->checkConnection();
51 next_id = fetchNextId();
55 m_writeStmt = m_conn->createStatement();
56 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
57 " ( rec_id, tag, version) "
58 " VALUES ( :1, :2, :3 ) ");
60 m_writeStmt->setInt(1, next_id);
64 throw(std::runtime_error(
std::string(
"ODVfeToRejectInfo::prepareWrite(): ") +
e.getMessage()));
72 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
73 if (ci->first ==
"VERSION")
74 setVersion(atoi(ci->second.c_str()));
75 if (ci->first ==
"TAG")
76 setConfigTag(ci->second);
81 this->checkConnection();
86 m_writeStmt->setString(2, this->getConfigTag());
87 m_writeStmt->setInt(3, this->getVersion());
89 m_writeStmt->executeUpdate();
92 throw(std::runtime_error(
std::string(
"ODVfeToRejectInfo::writeDB(): ") +
e.getMessage()));
95 if (!this->fetchID()) {
96 throw(std::runtime_error(
"ODVfeToRejectInfo::writeDB: Failed to write"));
98 int old_version = this->getVersion();
99 m_readStmt = m_conn->createStatement();
100 this->fetchData(
this);
101 m_conn->terminateStatement(m_readStmt);
102 if (this->getVersion() != old_version)
103 std::cout <<
"ODVfeToRejectInfo>>WARNING version is " << getVersion() << endl;
108 this->checkConnection();
110 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
111 throw(std::runtime_error(
"ODVfeToRejectInfo::fetchData(): no Id defined for this ODVfeToRejectInfo "));
115 if (
result->getId() != 0) {
116 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where rec_id = :1 ");
117 m_readStmt->setInt(1,
result->getId());
118 }
else if (!
result->getConfigTag().empty()) {
119 if (
result->getVersion() != 0) {
120 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
122 " and version = :version ");
123 m_readStmt->setString(1,
result->getConfigTag());
124 m_readStmt->setInt(2,
result->getVersion());
127 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" WHERE tag = :1 and version= (select max(version) from " +
128 getTable() +
" where tag=:2) ");
129 m_readStmt->setString(1,
result->getConfigTag());
130 m_readStmt->setString(2,
result->getConfigTag());
135 throw(std::runtime_error(
"ODVfeToRejectInfo::fetchData(): no Id defined for this record "));
138 ResultSet* rset = m_readStmt->executeQuery();
144 result->setId(rset->getInt(1));
145 result->setConfigTag(rset->getString(2));
146 result->setVersion(rset->getInt(3));
149 throw(std::runtime_error(
std::string(
"ODVfeToRejectInfo::fetchData(): ") +
e.getMessage()));
159 this->checkConnection();
162 Statement* stmt = m_conn->createStatement();
163 stmt->setSQL(
"SELECT rec_id FROM " + getTable() +
" WHERE tag=:1 and version=:2 ");
165 stmt->setString(1, getConfigTag());
166 stmt->setInt(2, getVersion());
168 ResultSet* rset = stmt->executeQuery();
171 m_ID = rset->getInt(1);
175 m_conn->terminateStatement(stmt);
177 throw(std::runtime_error(
std::string(
"ODVfeToRejectInfo::fetchID: ") +
e.getMessage()));