33 this->checkConnection();
36 Statement* stmt = m_conn->createStatement();
38 "SELECT def_id FROM location_def WHERE " 39 "location = :location");
40 stmt->setString(1, m_loc);
42 ResultSet* rset = stmt->executeQuery();
45 m_ID = rset->getInt(1);
49 m_conn->terminateStatement(stmt);
50 }
catch (SQLException&
e) {
51 throw(std::runtime_error(
"LocationDef::fetchID: " + e.getMessage()));
58 this->checkConnection();
61 Statement* stmt = m_conn->createStatement();
63 stmt->setSQL(
"SELECT location FROM location_def WHERE def_id = :1");
66 ResultSet* rset = stmt->executeQuery();
68 m_loc = rset->getString(1);
71 throw(std::runtime_error(
"LocationDef::setByID: Given def_id is not in the database"));
74 m_conn->terminateStatement(stmt);
75 }
catch (SQLException&
e) {
76 throw(std::runtime_error(
"LocationDef::setByID: " + e.getMessage()));
81 this->checkConnection();
83 Statement* stmt = m_conn->createStatement();
84 stmt->setSQL(
"SELECT def_id FROM location_def ORDER BY def_id");
85 ResultSet* rset = stmt->executeQuery();
90 while (rset->next()) {
91 locationDef.
setByID(rset->getInt(1));
92 fillVec->push_back(locationDef);
94 }
catch (SQLException&
e) {
95 throw(std::runtime_error(
"LocationDef::fetchAllDefs: " + e.getMessage()));
void fetchAllDefs(std::vector< LocationDef > *fillVec) noexcept(false)
void setByID(int id) noexcept(false) override
std::string getLocation() const
int fetchID() noexcept(false) override
void setLocation(std::string loc)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)