15 m_writeStmt =
nullptr;
38 this->checkConnection();
40 m_readStmt = m_conn->createStatement();
41 m_readStmt->setSQL(
"select COND2CONF_INFO_SQ.NextVal from DUAL ");
42 ResultSet* rset = m_readStmt->executeQuery();
43 while (rset->next()) {
47 m_conn->terminateStatement(m_readStmt);
51 throw(std::runtime_error(
std::string(
"ODCond2ConfInfo::fetchNextId(): ") +
e.getMessage()));
57 if (!getType().
empty()) {
59 this->checkConnection();
60 m_readStmt = m_conn->createStatement();
61 m_readStmt->setSQL(
"select def_id from COND2CONF_TYPE_DEF where rec_type=" + getType());
62 ResultSet* rset = m_readStmt->executeQuery();
63 while (rset->next()) {
64 m_typ_id = rset->getInt(1);
66 m_conn->terminateStatement(m_readStmt);
69 throw(std::runtime_error(
std::string(
"ODCond2ConfInfo::fetchParents(): ") +
e.getMessage()));
74 if (!getLocation().empty()) {
76 this->checkConnection();
77 m_readStmt = m_conn->createStatement();
78 m_readStmt->setSQL(
"select def_id from location_def where location=" + getLocation());
79 ResultSet* rset = m_readStmt->executeQuery();
80 while (rset->next()) {
81 m_loc_id = rset->getInt(1);
83 m_conn->terminateStatement(m_readStmt);
85 throw(std::runtime_error(
std::string(
"ODCond2ConfInfo::fetchParents(): ") +
e.getMessage()));
92 this->checkConnection();
96 next_id = fetchNextId();
101 m_writeStmt = m_conn->createStatement();
102 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
103 " ( rec_id, rec_type_id, rec_date, " 104 "location_id, run_number, short_desc ) " 105 " VALUES ( :1, :2, :3 , :4, :5, :6 ) ");
107 m_writeStmt->setInt(1, next_id);
108 m_writeStmt->setInt(3, m_typ_id);
109 m_writeStmt->setInt(4, m_loc_id);
114 throw(std::runtime_error(
std::string(
"ODCond2ConfInfo::prepareWrite(): ") +
e.getMessage()));
122 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
125 std::cout <<
"method not yet implemented" << std::endl;
129 this->checkConnection();
130 this->checkPrepare();
133 if (m_rec_time.isNull()) {
134 int very_old_time = 0;
135 m_rec_time =
Tm(very_old_time);
139 m_writeStmt->setDate(3,
dh.tmToDate(this->m_rec_time));
141 m_writeStmt->setString(6, this->getDescription());
143 m_writeStmt->executeUpdate();
146 throw(std::runtime_error(
std::string(
"ODCond2ConfInfo::writeDB(): ") +
e.getMessage()));
149 if (!this->fetchID()) {
150 throw(std::runtime_error(
"ODCond2ConfInfo::writeDB: Failed to write"));
155 this->checkConnection();
160 if (
result->getId() == 0) {
161 throw(std::runtime_error(
"ODCond2ConfInfo::fetchData(): no Id defined for this ODCond2ConfInfo "));
166 "SELECT rec_id, REC_TYPE, rec_date, location, " 167 "run_number, short_desc, db_timestamp FROM " +
169 " , COND2CONF_TYPE_DEF , location_def " 170 " where rec_id = :1 AND COND2CONF_TYPE_DEF.def_id=" +
171 getTable() +
".REC_TYPE_ID AND location_def.def_id=LOCATION_ID ");
172 m_readStmt->setInt(1,
result->getId());
173 ResultSet* rset = m_readStmt->executeQuery();
181 result->setType(rset->getString(2));
182 Date startDate = rset->getDate(3);
183 result->setLocation(rset->getString(4));
184 result->setRunNumber(rset->getInt(5));
185 result->setDescription(rset->getString(6));
186 Date endDate = rset->getDate(7);
188 m_rec_time =
dh.dateToTm(startDate);
189 m_db_time =
dh.dateToTm(endDate);
192 throw(std::runtime_error(
std::string(
"ODCond2ConfInfo::fetchData(): ") +
e.getMessage()));
202 this->checkConnection();
207 Statement* stmt = m_conn->createStatement();
208 stmt->setSQL(
"SELECT rec_id FROM " + getTable() +
209 "WHERE rec_type_id=:1 and (run_number=:2 or short_desc=:3 ) order by rec_id DESC ");
211 stmt->setInt(1, m_typ_id);
213 stmt->setString(3, getDescription());
215 ResultSet* rset = stmt->executeQuery();
218 m_ID = rset->getInt(1);
222 m_conn->terminateStatement(stmt);
224 throw(std::runtime_error(
std::string(
"ODCond2ConfInfo::fetchID: ") +
e.getMessage()));
void setParameters(const std::map< std::string, std::string > &my_keys_map)
int fetchNextId() noexcept(false)
void writeDB() noexcept(false)
void prepareWrite() noexcept(false) override
void fetchParents() noexcept(false)
~ODCond2ConfInfo() override
oracle::occi::Statement Statement
def getRunNumber(filename)
static unsigned int getId()
oracle::occi::SQLException SQLException
void clear(HadCaloObj &c)
int fetchID() noexcept(false)
void fetchData(ODCond2ConfInfo *result) noexcept(false)