133{
134 RunNumberList list;
135 try {
136 const char* cmd = "select node, runtype, expno, runno, id, "
137 "extract(epoch from record_time) as record_time from runnumber_new";
138 if (node.size() == 0) {
139 if (expno == 0) {
140 if (runno_max > 0) {
141 m_db.execute("%s where runno >= %d and runno <= %d order by id", cmd, runno_min, runno_max);
142 } else {
143 m_db.execute("%s where runno >= %d order by id", cmd, runno_min);
144 }
145 } else {
146 if (runno_max > 0) {
147 m_db.execute("%s where expno = %d and runno >= %d and runno <= %d order by id",
148 cmd, expno, runno_min, runno_max);
149 } else {
150 m_db.execute("%s where expno = %d and runno >= %d order by id", cmd, expno, runno_min);
151 }
152 }
153 } else {
154 if (expno == 0) {
155 if (runno_max > 0) {
156 m_db.execute("%s where node = '%s' and runno >= %d and runno <= %d order by id",
157 cmd, node.c_str(), runno_min, runno_max);
158 } else {
159 m_db.execute("%s where node = '%s' and runno >= %d order by id", cmd, node.c_str(), runno_min);
160 }
161 } else {
162 if (runno_max > 0) {
163 m_db.execute("%s where node = '%s' and expno = %d and runno >= %d and runno <= %d order by id",
164 cmd, node.c_str(), expno, runno_min, runno_max);
165 } else {
166 m_db.execute("%s where node = '%s' and expno = %d and runno >= %d order by id",
167 cmd, node.c_str(), expno, runno_min);
168 }
169 }
170 }
171 const DBRecordList record_v(m_db.loadRecords());
172 for (DBRecordList::const_iterator it = record_v.begin();
173 it != record_v.end(); ++it) {
174 const DBRecord& record(*it);
175 list.push_back(RunNumber(record.get("node"), record.get("runtype"),
176 record.getInt("expno"), record.getInt("runno"),
177 record.getInt("id"), record.getInt("record_time")));
178 }
179 } catch (const DBHandlerException& e) {
180 LogFile::error("DB access error : %s", e.what());
181 }
182 return list;
183}