16 m_writeStmt =
nullptr;
31 this->checkConnection();
33 m_readStmt = m_conn->createStatement();
34 m_readStmt->setSQL(
"select FE_CONFIG_PED_SQ.NextVal from DUAL ");
35 ResultSet* rset = m_readStmt->executeQuery();
36 while (rset->next()) {
40 m_conn->terminateStatement(m_readStmt);
44 throw(std::runtime_error(
std::string(
"FEConfigPedInfo::fetchNextId(): ") +
e.getMessage()));
49 this->checkConnection();
53 next_id = fetchNextId();
57 m_writeStmt = m_conn->createStatement();
58 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
59 " ( ped_conf_id, tag, version, iov_id) "
60 " VALUES ( :1, :2, :3 , :4) ");
62 m_writeStmt->setInt(1, next_id);
66 throw(std::runtime_error(
std::string(
"FEConfigPedInfo::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);
79 if (ci->first ==
"IOV_ID")
80 setIOVId(atoi(ci->second.c_str()));
85 this->checkConnection();
90 m_writeStmt->setString(2, this->getConfigTag());
91 m_writeStmt->setInt(3, this->getVersion());
92 m_writeStmt->setInt(4, this->getIOVId());
94 m_writeStmt->executeUpdate();
97 throw(std::runtime_error(
std::string(
"FEConfigPedInfo::writeDB(): ") +
e.getMessage()));
100 if (!this->fetchID()) {
101 throw(std::runtime_error(
"FEConfigPedInfo::writeDB: Failed to write"));
106 this->checkConnection();
108 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
109 throw(std::runtime_error(
"FEConfigPedInfo::fetchData(): no Id defined for this FEConfigPedInfo "));
115 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where ( ped_conf_id= :1 or (tag=:2 AND version=:3 ) )");
116 m_readStmt->setInt(1,
result->getId());
117 m_readStmt->setString(2,
result->getConfigTag());
118 m_readStmt->setInt(3,
result->getVersion());
119 ResultSet* rset = m_readStmt->executeQuery();
125 result->setId(rset->getInt(1));
126 result->setConfigTag(rset->getString(2));
127 result->setVersion(rset->getInt(3));
128 result->setIOVId(rset->getInt(4));
129 Date dbdate = rset->getDate(5);
130 result->setDBTime(
dh.dateToTm(dbdate));
133 throw(std::runtime_error(
std::string(
"FEConfigPedInfo::fetchData(): ") +
e.getMessage()));
138 this->checkConnection();
143 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where ped_conf_id = ( select max( ped_conf_id) from " +
145 ResultSet* rset = m_readStmt->executeQuery();
149 result->setId(rset->getInt(1));
150 result->setConfigTag(rset->getString(2));
151 result->setVersion(rset->getInt(3));
152 result->setIOVId(rset->getInt(4));
153 Date dbdate = rset->getDate(5);
154 result->setDBTime(
dh.dateToTm(dbdate));
157 throw(std::runtime_error(
std::string(
"FEConfigPedInfo::fetchData(): ") +
e.getMessage()));
167 this->checkConnection();
170 Statement* stmt = m_conn->createStatement();
171 stmt->setSQL(
"SELECT ped_conf_id FROM " + getTable() +
" WHERE tag=:1 and version=:2 ");
173 stmt->setString(1, getConfigTag());
174 stmt->setInt(2, getVersion());
176 ResultSet* rset = stmt->executeQuery();
179 m_ID = rset->getInt(1);
183 m_conn->terminateStatement(stmt);
185 throw(std::runtime_error(
std::string(
"FEConfigPedInfo::fetchID: ") +
e.getMessage()));
192 this->checkConnection();
197 Statement* stmt = m_conn->createStatement();
199 stmt->setSQL(
"SELECT * FROM fe_config_ped_info WHERE ped_conf_id = :1");
202 ResultSet* rset = stmt->executeQuery();
204 this->setId(rset->getInt(1));
205 this->setConfigTag(rset->getString(2));
206 this->setVersion(rset->getInt(3));
207 this->setIOVId(rset->getInt(4));
208 Date dbdate = rset->getDate(5);
209 this->setDBTime(
dh.dateToTm(dbdate));
211 throw(std::runtime_error(
"FEConfigPedInfo::setByID: Given config_id is not in the database"));
214 m_conn->terminateStatement(stmt);
216 throw(std::runtime_error(
std::string(
"FEConfigPedInfo::setByID: ") +
e.getMessage()));