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);
44 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::fetchNextId(): ") +
e.getMessage()));
49 this->checkConnection();
53 next_id = fetchNextId();
57 m_writeStmt = m_conn->createStatement();
58 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
59 " ( rec_id, tag, version) " 60 " VALUES ( :1, :2, :3 ) ");
62 m_writeStmt->setInt(1, next_id);
66 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::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 ==
"VERSION")
76 setVersion(atoi(ci->second.c_str()));
77 if (ci->first ==
"TAG")
78 setConfigTag(ci->second);
83 this->checkConnection();
88 m_writeStmt->setString(2, this->getConfigTag());
89 m_writeStmt->setInt(3, this->getVersion());
91 m_writeStmt->executeUpdate();
94 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::writeDB(): ") +
e.getMessage()));
98 if (!this->fetchID()) {
99 throw(std::runtime_error(
"ODFEDelaysInfo::writeDB: Failed to write"));
101 int old_version = this->getVersion();
102 m_readStmt = m_conn->createStatement();
103 this->fetchData(
this);
104 m_conn->terminateStatement(m_readStmt);
105 if (this->getVersion() != old_version)
106 std::cout <<
"ODFEDelaysInfo>>WARNING version is " << getVersion() << endl;
111 this->checkConnection();
114 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
115 throw(std::runtime_error(
"ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
119 if (
result->getId() != 0) {
120 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where rec_id = :1 ");
121 m_readStmt->setInt(1,
result->getId());
122 }
else if (!
result->getConfigTag().empty()) {
123 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where tag=:1 AND version=:2 ");
124 m_readStmt->setString(1,
result->getConfigTag());
125 m_readStmt->setInt(2,
result->getVersion());
128 throw(std::runtime_error(
"ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
131 ResultSet* rset = m_readStmt->executeQuery();
136 result->setId(rset->getInt(1));
137 result->setConfigTag(rset->getString(2));
138 result->setVersion(rset->getInt(3));
141 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::fetchData(): ") +
e.getMessage()));
151 this->checkConnection();
154 Statement* stmt = m_conn->createStatement();
155 stmt->setSQL(
"SELECT rec_id FROM " + getTable() +
"WHERE tag=:1 and version=:2 ");
157 stmt->setString(1, getConfigTag());
158 stmt->setInt(2, getVersion());
160 ResultSet* rset = stmt->executeQuery();
163 m_ID = rset->getInt(1);
167 m_conn->terminateStatement(stmt);
169 throw(std::runtime_error(
std::string(
"ODFEDelaysInfo::fetchID: ") +
e.getMessage()));
void writeDB() noexcept(false)
int fetchID() noexcept(false)
void fetchData(ODFEDelaysInfo *result) noexcept(false)
void setParameters(const std::map< std::string, std::string > &my_keys_map)
void prepareWrite() noexcept(false) override
oracle::occi::Statement Statement
static unsigned int getId()
oracle::occi::SQLException SQLException
~ODFEDelaysInfo() override
int fetchNextId() noexcept(false)