15 m_writeStmt =
nullptr;
30 this->checkConnection();
32 m_readStmt = m_conn->createStatement();
33 m_readStmt->setSQL(
"select COND2CONF_INFO_SQ.NextVal from DUAL ");
34 ResultSet* rset = m_readStmt->executeQuery();
35 while (rset->next()) {
39 m_conn->terminateStatement(m_readStmt);
43 throw(std::runtime_error(
std::string(
"ODFEWeightsInfo::fetchNextId(): ") +
e.getMessage()));
48 this->checkConnection();
52 next_id = fetchNextId();
56 m_writeStmt = m_conn->createStatement();
57 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
58 " ( rec_id, tag, version ) "
59 " VALUES ( :1, :2, :3 ) ");
61 m_writeStmt->setInt(1, next_id);
65 throw(std::runtime_error(
std::string(
"ODFEWeightsInfo::prepareWrite(): ") +
e.getMessage()));
73 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
74 if (ci->first ==
"VERSION")
75 setVersion(atoi(ci->second.c_str()));
76 if (ci->first ==
"TAG")
77 setConfigTag(ci->second);
82 this->checkConnection();
87 m_writeStmt->setString(2, this->getConfigTag());
88 m_writeStmt->setInt(3, this->getVersion());
89 m_writeStmt->executeUpdate();
92 throw(std::runtime_error(
std::string(
"ODFEWeightsInfo::writeDB(): ") +
e.getMessage()));
96 if (!this->fetchID()) {
97 throw(std::runtime_error(
"ODFEWeightsInfo::writeDB: Failed to write"));
99 int old_version = this->getVersion();
100 m_readStmt = m_conn->createStatement();
101 this->fetchData(
this);
102 m_conn->terminateStatement(m_readStmt);
103 if (this->getVersion() != old_version)
104 std::cout <<
"ODFEWeightsInfo>>WARNING version is " << getVersion() << endl;
109 this->checkConnection();
111 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
112 throw(std::runtime_error(
"ODFEWeightsInfo::fetchData(): no Id defined for this ODFEWeightsInfo "));
116 if (
result->getId() != 0) {
117 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where rec_id = :1 ");
118 m_readStmt->setInt(1,
result->getId());
119 }
else if (!
result->getConfigTag().empty()) {
120 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where tag=:1 AND version=:2 ");
121 m_readStmt->setString(1,
result->getConfigTag());
122 m_readStmt->setInt(2,
result->getVersion());
125 throw(std::runtime_error(
"ODFEWeightsInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
128 ResultSet* rset = m_readStmt->executeQuery();
134 result->setId(rset->getInt(1));
135 result->setConfigTag(rset->getString(2));
136 result->setVersion(rset->getInt(3));
139 throw(std::runtime_error(
std::string(
"ODFEWeightsInfo::fetchData(): ") +
e.getMessage()));
149 this->checkConnection();
152 Statement* stmt = m_conn->createStatement();
153 stmt->setSQL(
"SELECT rec_id FROM " + getTable() +
"WHERE tag=:1 and version=:2 ");
155 stmt->setString(1, getConfigTag());
156 stmt->setInt(2, getVersion());
158 ResultSet* rset = stmt->executeQuery();
161 m_ID = rset->getInt(1);
165 m_conn->terminateStatement(stmt);
167 throw(std::runtime_error(
std::string(
"ODFEWeightsInfo::fetchID: ") +
e.getMessage()));