15 m_writeStmt =
nullptr;
46 this->checkConnection();
48 m_readStmt = m_conn->createStatement();
49 m_readStmt->setSQL(
"select fe_config_main_sq.NextVal from dual");
50 ResultSet* rset = m_readStmt->executeQuery();
51 while (rset->next()) {
54 m_conn->terminateStatement(m_readStmt);
58 throw cms::Exception(
"SQLException") <<
"FEConfigMainInfo::fetchNextId(): " <<
e.getMessage();
68 this->checkConnection();
72 std::cout <<
" tag/version " << getConfigTag() <<
"/" << getVersion() << std::endl;
75 Statement* stmt = m_conn->createStatement();
78 "SELECT conf_id from FE_CONFIG_MAIN " 80 " and version = :version ");
81 stmt->setString(1, m_config_tag);
82 stmt->setInt(2, m_version);
83 std::cout <<
" using query with version " << endl;
87 "SELECT conf_id from FE_CONFIG_MAIN " 88 "WHERE tag = :1 and version= (select max(version) from FE_CONFIG_MAIN where tag=:2) ");
89 stmt->setString(1, m_config_tag);
90 stmt->setString(2, m_config_tag);
91 std::cout <<
" using query WITHOUT version " << endl;
94 ResultSet* rset = stmt->executeQuery();
97 m_ID = rset->getInt(1);
102 m_conn->terminateStatement(stmt);
104 throw cms::Exception(
"SQLException") <<
"FEConfigMainInfo::fetchID: " <<
e.getMessage();
111 this->checkConnection();
113 int next_id = fetchNextId();
116 m_writeStmt = m_conn->createStatement();
118 "INSERT INTO fe_config_main (conf_id, ped_conf_id, lin_conf_id, lut_conf_id, fgr_conf_id, sli_conf_id, " 119 "wei_conf_id, spi_conf_id, tim_conf_id, bxt_conf_id, btt_conf_id, bst_conf_id, coke_conf_id, wei2_conf_id, " 120 "tag, version, description) " 121 " VALUES (:1, :2, :3 , :4, :5, :6 ,:7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17 )");
123 m_writeStmt->setInt(1, next_id);
127 throw cms::Exception(
"SQLException") <<
"FEConfigMainInfo::prepareWrite(): " <<
e.getMessage();
132 this->checkConnection();
133 this->checkPrepare();
139 m_writeStmt->setInt(2, this->getPedId());
140 m_writeStmt->setInt(3, this->getLinId());
141 m_writeStmt->setInt(4, this->getLUTId());
142 m_writeStmt->setInt(5, this->getFgrId());
143 m_writeStmt->setInt(6, this->getSliId());
144 m_writeStmt->setInt(7, this->getWeiId());
145 m_writeStmt->setInt(8, this->getSpiId());
146 m_writeStmt->setInt(9, this->getTimId());
147 m_writeStmt->setInt(10, this->getBxtId());
148 m_writeStmt->setInt(11, this->getBttId());
149 m_writeStmt->setInt(12, this->getBstId());
150 m_writeStmt->setInt(13, this->getCokeId());
151 m_writeStmt->setInt(14, this->getWei2Id());
152 m_writeStmt->setString(15, this->getConfigTag());
153 m_writeStmt->setInt(16, this->getVersion());
154 m_writeStmt->setString(17, this->getDescription());
155 m_writeStmt->executeUpdate();
158 throw cms::Exception(
"SQLException") <<
"FEConfigMainInfo::writeDB: " <<
e.getMessage();
161 if (!this->fetchID()) {
162 throw(std::runtime_error(
"FEConfigMainInfo::writeDB: Failed to write"));
166 cout <<
"FEConfigMainInfo::writeDB>> done inserting FEConfigMainInfo with id=" << m_ID << endl;
170 this->checkConnection();
175 Statement* stmt = m_conn->createStatement();
176 stmt->setSQL(
"SELECT max(conf_id) FROM fe_config_main ");
177 ResultSet* rset = stmt->executeQuery();
180 m_ID = rset->getInt(1);
184 m_conn->terminateStatement(stmt);
186 throw cms::Exception(
"SQLException") <<
"ODRunConfigInfo::fetchIDLast: " <<
e.getMessage();
194 this->checkConnection();
198 cout <<
"FEConfigMainInfo::setByID called for id " <<
id << endl;
201 Statement* stmt = m_conn->createStatement();
204 "SELECT conf_id, ped_conf_id, lin_conf_id, lut_conf_id, fgr_conf_id, sli_conf_id, wei_conf_id, spi_conf_id, " 205 "tim_conf_id, bxt_conf_id, btt_conf_id, bst_conf_id, coke_conf_id, wei2_conf_id, tag, version, description, " 206 "db_timestamp FROM FE_CONFIG_MAIN WHERE conf_id = :1 ");
209 ResultSet* rset = stmt->executeQuery();
211 setId(rset->getInt(1));
212 setPedId(rset->getInt(2));
213 setLinId(rset->getInt(3));
214 setLUTId(rset->getInt(4));
215 setFgrId(rset->getInt(5));
216 setSliId(rset->getInt(6));
217 setWeiId(rset->getInt(7));
218 setSpiId(rset->getInt(8));
219 setTimId(rset->getInt(9));
220 setBxtId(rset->getInt(10));
221 setBttId(rset->getInt(11));
222 setBstId(rset->getInt(12));
223 setCokeId(rset->getInt(13));
224 setWei2Id(rset->getInt(14));
225 setConfigTag(rset->getString(15));
226 setVersion(rset->getInt(16));
227 setDescription(rset->getString(17));
228 Date dbdate = rset->getDate(18);
229 setDBTime(
dh.dateToTm(dbdate));
232 throw(std::runtime_error(
"FEConfigMainInfo::setByID: Given cycle_id is not in the database"));
234 m_conn->terminateStatement(stmt);
236 throw cms::Exception(
"SQLException") <<
"FEConfigMainInfo::setByID: " <<
e.getMessage();
241 std::cout <<
" ### 1 getId from FEConfigMainInfo = " <<
result->getId() << std::endl;
244 this->checkConnection();
250 if (
result->getId() == 0) {
258 "SELECT conf_id, ped_conf_id, lin_conf_id, lut_conf_id, fgr_conf_id, sli_conf_id, wei_conf_id, spi_conf_id, " 259 "tim_conf_id, bxt_conf_id, btt_conf_id, bst_conf_id, coke_conf_id, wei2_conf_id, tag, version, description, " 260 "db_timestamp FROM FE_CONFIG_MAIN WHERE conf_id = :1 ");
262 std::cout <<
" ### 2 getId from FEConfigMainInfo = " <<
result->getId() << std::endl;
265 m_readStmt->setInt(1,
result->getId());
266 ResultSet* rset = m_readStmt->executeQuery();
270 result->setId(rset->getInt(1));
272 setPedId(rset->getInt(2));
273 setLinId(rset->getInt(3));
274 setLUTId(rset->getInt(4));
275 setFgrId(rset->getInt(5));
276 setSliId(rset->getInt(6));
277 setWeiId(rset->getInt(7));
278 setSpiId(rset->getInt(8));
279 setTimId(rset->getInt(9));
280 setBxtId(rset->getInt(10));
281 setBttId(rset->getInt(11));
282 setBstId(rset->getInt(12));
283 setCokeId(rset->getInt(13));
284 setWei2Id(rset->getInt(14));
286 result->setConfigTag(rset->getString(15));
287 result->setVersion(rset->getInt(16));
288 result->setDescription(rset->getString(17));
289 Date dbdate = rset->getDate(18);
290 result->setDBTime(
dh.dateToTm(dbdate));
293 throw cms::Exception(
"SQLException") <<
"FEConfigMainInfo::fetchData(): " <<
e.getMessage();
302 terminateWriteStatement();
303 }
catch (std::runtime_error&
e) {
void setByID(int id) noexcept(false)
int fetchNextId() noexcept(false)
int fetchID() noexcept(false)
void prepareWrite() noexcept(false) override
void writeDB() noexcept(false)
void insertConfig() noexcept(false)
void fetchData(FEConfigMainInfo *result) noexcept(false)
oracle::occi::Statement Statement
oracle::occi::SQLException SQLException
int fetchIDLast() noexcept(false)
~FEConfigMainInfo() override