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(
"ODFEPedestalOffsetInfo::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(
"ODFEPedestalOffsetInfo::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());
90 m_writeStmt->executeUpdate();
93 throw(std::runtime_error(
std::string(
"ODFEPedestalOffsetInfo::writeDB(): ") +
e.getMessage()));
97 if (!this->fetchID()) {
98 throw(std::runtime_error(
"ODFEPedestalOffsetInfo::writeDB: Failed to write"));
100 int old_version = this->getVersion();
101 m_readStmt = m_conn->createStatement();
102 this->fetchData(
this);
103 m_conn->terminateStatement(m_readStmt);
104 if (this->getVersion() != old_version)
105 std::cout <<
"ODFEPedestalOffsetInfo>>WARNING version is " << getVersion() << endl;
110 this->checkConnection();
112 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
113 throw(std::runtime_error(
"ODFEPedestalOffsetInfo::fetchData(): no Id defined for this ODFEPedestalOffsetInfo "));
117 if (
result->getId() != 0) {
118 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where rec_id = :1 ");
119 m_readStmt->setInt(1,
result->getId());
120 }
else if (!
result->getConfigTag().empty()) {
121 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where tag=:1 AND version=:2 ");
122 m_readStmt->setString(1,
result->getConfigTag());
123 m_readStmt->setInt(2,
result->getVersion());
126 throw(std::runtime_error(
"ODFEPedestalOffsetInfo::fetchData(): no Id defined for this record "));
129 ResultSet* rset = m_readStmt->executeQuery();
135 result->setId(rset->getInt(1));
136 result->setConfigTag(rset->getString(2));
137 result->setVersion(rset->getInt(3));
140 throw(std::runtime_error(
std::string(
"ODFEPedestalOffsetInfo::fetchData(): ") +
e.getMessage()));
145 this->checkConnection();
148 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where rec_id = ( select max(rec_id) from " + getTable() +
150 ResultSet* rset = m_readStmt->executeQuery();
154 result->setId(rset->getInt(1));
155 result->setConfigTag(rset->getString(2));
156 result->setVersion(rset->getInt(3));
159 throw(std::runtime_error(
std::string(
"ODFEPedestalOffsetInfo::fetchData(): ") +
e.getMessage()));
169 this->checkConnection();
172 Statement* stmt = m_conn->createStatement();
173 stmt->setSQL(
"SELECT rec_id FROM " + getTable() +
"WHERE tag=:1 and version=:2 ");
175 stmt->setString(1, getConfigTag());
176 stmt->setInt(2, getVersion());
178 ResultSet* rset = stmt->executeQuery();
181 m_ID = rset->getInt(1);
185 m_conn->terminateStatement(stmt);
187 throw(std::runtime_error(
std::string(
"ODFEPedestalOffsetInfo::fetchID: ") +
e.getMessage()));
void setParameters(const std::map< std::string, std::string > &my_keys_map)
void prepareWrite() noexcept(false) override
void writeDB() noexcept(false)
int fetchNextId() noexcept(false)
int fetchID() noexcept(false)
void fetchData(ODFEPedestalOffsetInfo *result) noexcept(false)
~ODFEPedestalOffsetInfo() override
oracle::occi::Statement Statement
static unsigned int getId()
void fetchLastData(ODFEPedestalOffsetInfo *result) noexcept(false)
oracle::occi::SQLException SQLException