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