14 m_writeStmt =
nullptr;
45 this->checkConnection();
47 m_readStmt = m_conn->createStatement();
48 m_readStmt->setSQL(
"select fe_config_main_sq.NextVal from dual");
49 ResultSet* rset = m_readStmt->executeQuery();
50 while (rset->next()) {
53 m_conn->terminateStatement(m_readStmt);
57 throw(std::runtime_error(
"FEConfigMainInfo::fetchNextId(): " +
e.getMessage()));
67 this->checkConnection();
71 std::cout <<
" tag/version " << getConfigTag() <<
"/" << getVersion() << std::endl;
74 Statement* stmt = m_conn->createStatement();
77 "SELECT conf_id from FE_CONFIG_MAIN "
79 " and version = :version ");
80 stmt->setString(1, m_config_tag);
81 stmt->setInt(2, m_version);
82 std::cout <<
" using query with version " << endl;
86 "SELECT conf_id from FE_CONFIG_MAIN "
87 "WHERE tag = :1 and version= (select max(version) from FE_CONFIG_MAIN where tag=:2) ");
88 stmt->setString(1, m_config_tag);
89 stmt->setString(2, m_config_tag);
90 std::cout <<
" using query WITHOUT version " << endl;
93 ResultSet* rset = stmt->executeQuery();
96 m_ID = rset->getInt(1);
101 m_conn->terminateStatement(stmt);
103 throw(std::runtime_error(
"FEConfigMainInfo::fetchID: " +
e.getMessage()));
110 this->checkConnection();
112 int next_id = fetchNextId();
115 m_writeStmt = m_conn->createStatement();
117 "INSERT INTO fe_config_main (conf_id, ped_conf_id, lin_conf_id, lut_conf_id, fgr_conf_id, sli_conf_id, "
118 "wei_conf_id, spi_conf_id, tim_conf_id, bxt_conf_id, btt_conf_id, bst_conf_id, coke_conf_id, wei2_conf_id, "
119 "tag, version, description) "
120 " VALUES (:1, :2, :3 , :4, :5, :6 ,:7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17 )");
122 m_writeStmt->setInt(1, next_id);
126 throw(std::runtime_error(
"FEConfigMainInfo::prepareWrite(): " +
e.getMessage()));
131 this->checkConnection();
132 this->checkPrepare();
138 m_writeStmt->setInt(2, this->getPedId());
139 m_writeStmt->setInt(3, this->getLinId());
140 m_writeStmt->setInt(4, this->getLUTId());
141 m_writeStmt->setInt(5, this->getFgrId());
142 m_writeStmt->setInt(6, this->getSliId());
143 m_writeStmt->setInt(7, this->getWeiId());
144 m_writeStmt->setInt(8, this->getSpiId());
145 m_writeStmt->setInt(9, this->getTimId());
146 m_writeStmt->setInt(10, this->getBxtId());
147 m_writeStmt->setInt(11, this->getBttId());
148 m_writeStmt->setInt(12, this->getBstId());
149 m_writeStmt->setInt(13, this->getCokeId());
150 m_writeStmt->setInt(14, this->getWei2Id());
151 m_writeStmt->setString(15, this->getConfigTag());
152 m_writeStmt->setInt(16, this->getVersion());
153 m_writeStmt->setString(17, this->getDescription());
154 m_writeStmt->executeUpdate();
157 throw(std::runtime_error(
"FEConfigMainInfo::writeDB: " +
e.getMessage()));
160 if (!this->fetchID()) {
161 throw(std::runtime_error(
"FEConfigMainInfo::writeDB: Failed to write"));
165 cout <<
"FEConfigMainInfo::writeDB>> done inserting FEConfigMainInfo with id=" << m_ID << endl;
169 this->checkConnection();
174 Statement* stmt = m_conn->createStatement();
175 stmt->setSQL(
"SELECT max(conf_id) FROM fe_config_main ");
176 ResultSet* rset = stmt->executeQuery();
179 m_ID = rset->getInt(1);
183 m_conn->terminateStatement(stmt);
185 throw(std::runtime_error(
"ODRunConfigInfo::fetchIDLast: " +
e.getMessage()));
193 this->checkConnection();
197 cout <<
"FEConfigMainInfo::setByID called for id " <<
id << endl;
200 Statement* stmt = m_conn->createStatement();
203 "SELECT conf_id, ped_conf_id, lin_conf_id, lut_conf_id, fgr_conf_id, sli_conf_id, wei_conf_id, spi_conf_id, "
204 "tim_conf_id, bxt_conf_id, btt_conf_id, bst_conf_id, coke_conf_id, wei2_conf_id, tag, version, description, "
205 "db_timestamp FROM FE_CONFIG_MAIN WHERE conf_id = :1 ");
208 ResultSet* rset = stmt->executeQuery();
210 setId(rset->getInt(1));
211 setPedId(rset->getInt(2));
212 setLinId(rset->getInt(3));
213 setLUTId(rset->getInt(4));
214 setFgrId(rset->getInt(5));
215 setSliId(rset->getInt(6));
216 setWeiId(rset->getInt(7));
217 setSpiId(rset->getInt(8));
218 setTimId(rset->getInt(9));
219 setBxtId(rset->getInt(10));
220 setBttId(rset->getInt(11));
221 setBstId(rset->getInt(12));
222 setCokeId(rset->getInt(13));
223 setWei2Id(rset->getInt(14));
224 setConfigTag(rset->getString(15));
225 setVersion(rset->getInt(16));
226 setDescription(rset->getString(17));
227 Date dbdate = rset->getDate(18);
228 setDBTime(
dh.dateToTm(dbdate));
231 throw(std::runtime_error(
"FEConfigMainInfo::setByID: Given cycle_id is not in the database"));
233 m_conn->terminateStatement(stmt);
235 throw(std::runtime_error(
"FEConfigMainInfo::setByID: " +
e.getMessage()));
240 std::cout <<
" ### 1 getId from FEConfigMainInfo = " <<
result->getId() << std::endl;
243 this->checkConnection();
249 if (
result->getId() == 0) {
257 "SELECT conf_id, ped_conf_id, lin_conf_id, lut_conf_id, fgr_conf_id, sli_conf_id, wei_conf_id, spi_conf_id, "
258 "tim_conf_id, bxt_conf_id, btt_conf_id, bst_conf_id, coke_conf_id, wei2_conf_id, tag, version, description, "
259 "db_timestamp FROM FE_CONFIG_MAIN WHERE conf_id = :1 ");
261 std::cout <<
" ### 2 getId from FEConfigMainInfo = " <<
result->getId() << std::endl;
264 m_readStmt->setInt(1,
result->getId());
265 ResultSet* rset = m_readStmt->executeQuery();
269 result->setId(rset->getInt(1));
271 setPedId(rset->getInt(2));
272 setLinId(rset->getInt(3));
273 setLUTId(rset->getInt(4));
274 setFgrId(rset->getInt(5));
275 setSliId(rset->getInt(6));
276 setWeiId(rset->getInt(7));
277 setSpiId(rset->getInt(8));
278 setTimId(rset->getInt(9));
279 setBxtId(rset->getInt(10));
280 setBttId(rset->getInt(11));
281 setBstId(rset->getInt(12));
282 setCokeId(rset->getInt(13));
283 setWei2Id(rset->getInt(14));
285 result->setConfigTag(rset->getString(15));
286 result->setVersion(rset->getInt(16));
287 result->setDescription(rset->getString(17));
288 Date dbdate = rset->getDate(18);
289 result->setDBTime(
dh.dateToTm(dbdate));
292 throw(std::runtime_error(
"FEConfigMainInfo::fetchData(): " +
e.getMessage()));
301 terminateWriteStatement();
302 }
catch (std::runtime_error&
e) {
307 throw(std::runtime_error(
"FEConfigMainInfo::insertConfig: Unknown exception caught"));