14 m_writeStmt =
nullptr;
43 this->checkConnection();
45 m_readStmt = m_conn->createStatement();
46 m_readStmt->setSQL(
"select fe_config_main_sq.NextVal from dual");
47 ResultSet* rset = m_readStmt->executeQuery();
48 while (rset->next()) {
51 m_conn->terminateStatement(m_readStmt);
55 throw(std::runtime_error(
"FEConfigMainInfo::fetchNextId(): " +
e.getMessage()));
65 this->checkConnection();
69 std::cout <<
" tag/version " << getConfigTag() <<
"/" << getVersion() << std::endl;
72 Statement* stmt = m_conn->createStatement();
75 "SELECT conf_id from FE_CONFIG_MAIN "
77 " and version = :version ");
78 stmt->setString(1, m_config_tag);
79 stmt->setInt(2, m_version);
80 std::cout <<
" using query with version " << endl;
84 "SELECT conf_id from FE_CONFIG_MAIN "
85 "WHERE tag = :1 and version= (select max(version) from FE_CONFIG_MAIN where tag=:2) ");
86 stmt->setString(1, m_config_tag);
87 stmt->setString(2, m_config_tag);
88 std::cout <<
" using query WITHOUT version " << endl;
91 ResultSet* rset = stmt->executeQuery();
94 m_ID = rset->getInt(1);
99 m_conn->terminateStatement(stmt);
101 throw(std::runtime_error(
"FEConfigMainInfo::fetchID: " +
e.getMessage()));
108 this->checkConnection();
110 int next_id = fetchNextId();
113 m_writeStmt = m_conn->createStatement();
115 "INSERT INTO fe_config_main (conf_id, ped_conf_id, lin_conf_id, lut_conf_id, fgr_conf_id, sli_conf_id, "
116 "wei_conf_id, spi_conf_id, tim_conf_id, bxt_conf_id, btt_conf_id, bst_conf_id, tag, version, description) "
117 " VALUES (:1, :2, :3 , :4, :5, :6 ,:7, :8, :9, :10, :11, :12, :13, :14, :15 )");
119 m_writeStmt->setInt(1, next_id);
123 throw(std::runtime_error(
"FEConfigMainInfo::prepareWrite(): " +
e.getMessage()));
128 this->checkConnection();
129 this->checkPrepare();
135 m_writeStmt->setInt(2, this->getPedId());
136 m_writeStmt->setInt(3, this->getLinId());
137 m_writeStmt->setInt(4, this->getLUTId());
138 m_writeStmt->setInt(5, this->getFgrId());
139 m_writeStmt->setInt(6, this->getSliId());
140 m_writeStmt->setInt(7, this->getWeiId());
141 m_writeStmt->setInt(8, this->getSpiId());
142 m_writeStmt->setInt(9, this->getTimId());
143 m_writeStmt->setInt(10, this->getBxtId());
144 m_writeStmt->setInt(11, this->getBttId());
145 m_writeStmt->setInt(12, this->getBstId());
146 m_writeStmt->setString(13, this->getConfigTag());
147 m_writeStmt->setInt(14, this->getVersion());
148 m_writeStmt->setString(15, this->getDescription());
149 m_writeStmt->executeUpdate();
152 throw(std::runtime_error(
"FEConfigMainInfo::writeDB: " +
e.getMessage()));
155 if (!this->fetchID()) {
156 throw(std::runtime_error(
"FEConfigMainInfo::writeDB: Failed to write"));
160 cout <<
"FEConfigMainInfo::writeDB>> done inserting FEConfigMainInfo with id=" << m_ID << endl;
164 this->checkConnection();
169 Statement* stmt = m_conn->createStatement();
170 stmt->setSQL(
"SELECT max(conf_id) FROM fe_config_main ");
171 ResultSet* rset = stmt->executeQuery();
174 m_ID = rset->getInt(1);
178 m_conn->terminateStatement(stmt);
180 throw(std::runtime_error(
"ODRunConfigInfo::fetchIDLast: " +
e.getMessage()));
188 this->checkConnection();
192 cout <<
"FEConfigMainInfo::setByID called for id " <<
id << endl;
195 Statement* stmt = m_conn->createStatement();
197 stmt->setSQL(
"SELECT * FROM FE_CONFIG_MAIN WHERE conf_id = :1 ");
200 ResultSet* rset = stmt->executeQuery();
202 setId(rset->getInt(1));
203 setPedId(rset->getInt(2));
204 setLinId(rset->getInt(3));
205 setLUTId(rset->getInt(4));
206 setFgrId(rset->getInt(5));
207 setSliId(rset->getInt(6));
208 setWeiId(rset->getInt(7));
209 setSpiId(rset->getInt(8));
210 setTimId(rset->getInt(9));
211 setBxtId(rset->getInt(10));
212 setBttId(rset->getInt(11));
213 setBstId(rset->getInt(12));
214 setConfigTag(rset->getString(13));
215 setVersion(rset->getInt(14));
216 setDescription(rset->getString(15));
217 Date dbdate = rset->getDate(16);
218 setDBTime(
dh.dateToTm(dbdate));
221 throw(std::runtime_error(
"FEConfigMainInfo::setByID: Given cycle_id is not in the database"));
223 m_conn->terminateStatement(stmt);
225 throw(std::runtime_error(
"FEConfigMainInfo::setByID: " +
e.getMessage()));
230 std::cout <<
" ### 1 getId from FEConfigMainInfo = " <<
result->getId() << std::endl;
233 this->checkConnection();
239 if (
result->getId() == 0) {
246 m_readStmt->setSQL(
"SELECT * FROM FE_CONFIG_MAIN WHERE conf_id = :1 ");
248 std::cout <<
" ### 2 getId from FEConfigMainInfo = " <<
result->getId() << std::endl;
251 m_readStmt->setInt(1,
result->getId());
252 ResultSet* rset = m_readStmt->executeQuery();
256 result->setId(rset->getInt(1));
258 setPedId(rset->getInt(2));
259 setLinId(rset->getInt(3));
260 setLUTId(rset->getInt(4));
261 setFgrId(rset->getInt(5));
262 setSliId(rset->getInt(6));
263 setWeiId(rset->getInt(7));
264 setSpiId(rset->getInt(8));
265 setTimId(rset->getInt(9));
266 setBxtId(rset->getInt(10));
267 setBttId(rset->getInt(11));
268 setBstId(rset->getInt(12));
270 result->setConfigTag(rset->getString(13));
271 result->setVersion(rset->getInt(14));
272 result->setDescription(rset->getString(15));
273 Date dbdate = rset->getDate(16);
274 result->setDBTime(
dh.dateToTm(dbdate));
277 throw(std::runtime_error(
"FEConfigMainInfo::fetchData(): " +
e.getMessage()));
286 terminateWriteStatement();
287 }
catch (std::runtime_error&
e) {
292 throw(std::runtime_error(
"FEConfigMainInfo::insertConfig: Unknown exception caught"));