我不知道如何使用 JavaScript,但我知道如何使用 Oracle。所以,给你。
SQL> with flight_schedule (flight, sched) as
2 (select 'SPX-14' , to_date('12.01.2018 22:00', 'dd.mm.yyyy hh24:mi') from dual union
3 select '67P' , to_date('12.01.2018 22:15', 'dd.mm.yyyy hh24:mi') from dual union
4 select 'OA-9' , to_date('12.01.2018 22:40', 'dd.mm.yyyy hh24:mi') from dual union
5 select '555' , to_date('12.01.2018 18:30', 'dd.mm.yyyy hh24:mi') from dual union
6 select 'DRAGONX', to_date('12.01.2018 19:00', 'dd.mm.yyyy hh24:mi') from dual union
7 select '34R' , to_date('12.01.2018 19:28', 'dd.mm.yyyy hh24:mi') from dual),
8 static_values as
9 (select 1 what, 'UPCOMING' statval from dual union
10 select 3 , 'PAST FLIGHTS' from dual
11 ),
12 --
13 prep as
14 (-- Static values
15 select what, statval flight, null sched
16 from static_values x
17 union
18 -- Upcoming flights
19 select 2 what, flight, sched
20 from flight_schedule
21 where sched > sysdate
22 union
23 -- Past flights
24 select 4 what, flight, sched
25 from flight_schedule
26 where sched <= sysdate
27 )
28 select flight, sched scheduled_time
29 from prep
30 order by what, sched;
FLIGHT SCHEDULED_TIME
------------ ----------------
UPCOMING
SPX-14 12.01.2018 22:00
67P 12.01.2018 22:15
OA-9 12.01.2018 22:40
PAST FLIGHTS
555 12.01.2018 18:30
DRAGONX 12.01.2018 19:00
34R 12.01.2018 19:28
8 rows selected.
SQL>
几点注意事项:
- 当前的“sysdate”(关于这个例子)是 12.01.2018 21:00
- flight_schedule 是实际的“航班时刻表”,有航班和时刻表
- 它们与静态值“联合”。WHAT 列显示放置这些值的位置(即指向它们的排序位置)
- PREP 表准备这些值;静态的是微不足道的,而即将到来和过去的航班取决于“sysdate”
哦,是的 - 还有一件事:因为这是 Apex LoV,您必须准确选择两个值:显示和返回值;这些是什么,你会知道得更好(可能是 FLIGHT 和它的 ID,或类似的东西)。