14 m_writeStmt =
nullptr;
34 this->checkConnection();
36 m_readStmt = m_conn->createStatement();
37 m_readStmt->setSQL(
"select ecal_scan_config_sq.NextVal from dual");
38 ResultSet* rset = m_readStmt->executeQuery();
39 while (rset->next()) {
42 m_conn->terminateStatement(m_readStmt);
46 throw(std::runtime_error(
std::string(
"ODScanConfig::fetchNextId(): ") +
e.getMessage()));
54 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
55 if (ci->first ==
"SCAN_ID")
56 setConfigTag(ci->second);
57 if (ci->first ==
"TYPE_ID")
58 setTypeId(atoi(ci->second.c_str()));
59 if (ci->first ==
"TYPE" || ci->first ==
"SCAN_TYPE")
60 setScanType(ci->second);
61 if (ci->first ==
"FROM" || ci->first ==
"FROM_VAL")
62 setFromVal(atoi(ci->second.c_str()));
63 if (ci->first ==
"TO" || ci->first ==
"TO_VAL")
64 setToVal(atoi(ci->second.c_str()));
65 if (ci->first ==
"STEP")
66 setStep(atoi(ci->second.c_str()));
71 this->checkConnection();
72 int next_id = fetchNextId();
75 m_writeStmt = m_conn->createStatement();
77 "INSERT INTO ECAL_scan_dat ( scan_id, scan_tag ,"
78 " type_id, scan_type , FROM_VAL , TO_VAL, STEP )"
79 " VALUES ( :1, :2, :3, :4, :5, :6, :7)");
80 m_writeStmt->setInt(1, next_id);
84 throw(std::runtime_error(
std::string(
"ODScanConfig::prepareWrite(): ") +
e.getMessage()));
89 this->checkConnection();
94 m_writeStmt->setString(2, this->getConfigTag());
96 m_writeStmt->setInt(3, this->getTypeId());
97 m_writeStmt->setString(4, this->getScanType());
98 m_writeStmt->setInt(5, this->getFromVal());
99 m_writeStmt->setInt(6, this->getToVal());
100 m_writeStmt->setInt(7, this->getStep());
102 m_writeStmt->executeUpdate();
105 throw(std::runtime_error(
std::string(
"ODScanConfig::writeDB(): ") +
e.getMessage()));
108 if (!this->fetchID()) {
109 throw(std::runtime_error(
"ODScanConfig::writeDB: Failed to write"));
114 this->checkConnection();
116 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
117 throw(std::runtime_error(
"ODScanConfig::fetchData(): no Id defined for this ODScanConfig "));
123 "FROM ECAL_SCAN_DAT "
124 " where (scan_id = :1 or scan_tag=:2 )");
125 m_readStmt->setInt(1,
result->getId());
126 m_readStmt->setString(2,
result->getConfigTag());
128 ResultSet* rset = m_readStmt->executeQuery();
133 result->setId(rset->getInt(1));
134 result->setConfigTag(rset->getString(2));
135 result->setTypeId(rset->getInt(3));
136 result->setScanType(rset->getString(4));
137 result->setFromVal(rset->getInt(5));
138 result->setToVal(rset->getInt(6));
139 result->setStep(rset->getInt(7));
142 throw(std::runtime_error(
std::string(
"ODScanConfig::fetchData(): ") +
e.getMessage()));
152 this->checkConnection();
155 Statement* stmt = m_conn->createStatement();
157 "SELECT scan_id FROM ecal_scan_dat "
158 "WHERE scan_tag=:scan_tag ");
160 stmt->setString(1, getConfigTag());
162 ResultSet* rset = stmt->executeQuery();
165 m_ID = rset->getInt(1);
169 m_conn->terminateStatement(stmt);
171 throw(std::runtime_error(
std::string(
"ODScanConfig::fetchID: ") +
e.getMessage()));