这是Observable.from(new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return new Iterator<T>() {
@Override
public boolean hasNext() {
return hasNextPage(currentPageKey);
}
@Override
public T next() {
page = getNextPage(currentPageKey);
currentPageKey = page.getKey();
return page;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
});
表:
presentation
我想在ID PRESENTATIONDAY PRESENTATIONSTART PRESENTATIONEND PRESENTATIONSTARTDATE PRESENTATIONENDDATE
622 Monday 12:00:00 02:00:00 01-05-2016 04-06-2016
623 Tuesday 12:00:00 02:00:00 01-05-2016 04-06-2016
624 Wednesday 08:00:00 10:00:00 01-05-2016 04-06-2016
625 Thursday 10:00:00 12:00:00 01-05-2016 04-06-2016
表格中插入availabledate
。这是我目前的查询:
schedule
根据insert into SCHEDULE (studentID,studentName,projectTitle,supervisorID,
supervisorName,examinerID,examinerName,exavailableID,
availableday,availablestart,availableend,
availabledate) //PROBLEM STARTS HERE
values (?,?,?,?,?,?,?,?,?,?,?,?));
检索值availabledate
。例如,如果exavailableID
= 2,exavailableID
=星期一,availableday
= 12 pm,availablestart
= 2 pm。
只会在availableend
表的PRESENTATIONSTARTDATE
到PRESENTATIONENDDATE
之间选择日期。
在presentation
表格中,它会将presentation
,PRESENTATIONDAY
和PRESENTATIONDATESTART
与PRESENTATIONDATEEND
,availableday
和availablestart
匹配到获取所有可能日期的列表。
这是根据特定日期获取所有可能日期列表的查询:
availableend
此查询结果为:
select
A.PRESENTATIONID,
A.PRESENTATIONDAY,
A.PRESENTATIONDATESTART+delta LIST_DATE
from
PRESENTATION A,
(
select level-1 as delta
from dual
connect by level-1 <= (
select max(PRESENTATIONDATEEND- PRESENTATIONDATESTART) from PRESENTATION
)
)
where A.PRESENTATIONDATESTART+delta <= A.PRESENTATIONDATEEND
and
a.presentationday = trim(to_char(A.PRESENTATIONDATESTART+delta, 'Day'))
order by 1,2,3;
它会自动从622 Monday 02-05-2016 12:00:00
...
622 Monday 30-05-2016 12:00:00
623 Tuesday 03-05-2016 12:00:00
...
623 Tuesday 31-05-2016 12:00:00
624 Wednesday 04-05-2016 12:00:00
...
624 Wednesday 01-06-2016 12:00:00
625 Thursday 05-05-2016 12:00:00
...
625 Thursday 02-06-2016 12:00:00
查询中分配日期以插入SELECT
表中。但是,每个日期只能使用4次。一旦达到4次,它将进入下一个日期。例如,如果星期一,&#39; 02-05-2016&#39;到&#39; 09-05-2016&#39;
如何将这两个查询(schedule
和INSERT
)合并,以获得如下结果:
SELECT
简而言之,我想根据日期,开始时间和结束时间来使用 StudentName projectTitle SupervisorID ExaminerID availableday availablestart availableend availabledate
abc Hello 1024 1001 MONDAY 12.00pm 2.00pm 02-05-2016
def Hi 1024 1001 MONDAY 12.00pm 2.00pm 02-05-2016
ghi Hey 1002 1004 MONDAY 12.00pm 2.00pm 02-05-2016
xxx hhh 1020 1011 MONDAY 12.00pm 2.00pm 02-05-2016
jkl hhh 1027 1010 MONDAY 12.00pm 2.00pm 09-05-2016
try ttt 1001 1011 MONDAY 12.00pm 2.00pm 09-05-2016
654 bbb 1007 1012 MONDAY 12.00pm 2.00pm 09-05-2016
gyg 888 1027 1051 MONDAY 12.00pm 2.00pm 09-05-2016
yyi 333 1004 1022 TUESDAY 12.00pm 2.00pm 03-05-2016
fff 111 1027 1041 TUESDAY ..
ggg 222 1032 1007 TUESDAY .. .. .. ..
hhh 444 1007 1001 TUESDAY 12.00pm 2.00pm 03-05-2016
and so on :)
表中的日期列表来插入查询,其中每个日期仅使用4次。谢谢!
答案 0 :(得分:0)
我不确定这种语法是否适用于oracle(并且没有好的方法可以检查),但更改插入的选择部分可能会也可能不起作用。
select
A.PRESENTATIONID,
A.PRESENTATIONDAY,
A.PRESENTATIONDATESTART+delta LIST_DATE
from
PRESENTATION A,
(
select level-1 as delta
from dual
connect by level-1 <= (
select max(PRESENTATIONDATEEND - PRESENTATIONDATESTART) from PRESENTATION
)
),
--MIGHT NEED ADDITIONAL LOGIC FOR THE EXAVAILABLEID COMPARISON
(SELECT count(S.*) as counter FROM SCHEDULE S WHERE S.EXAVAILABLEID=A.ID) C
where A.PRESENTATIONDATESTART+delta <= A.PRESENTATIONDATEEND
and
a.presentationday = trim(to_char(A.PRESENTATIONDATESTART+delta, 'Day'))
and
C.counter<4
order by 1,2,3;
编辑:更改了运营商。曾经> =之前。放置在哪里检查在正确的地方。删除了别名。
EDIT2:将语法更改为计数器select语句是from子句的一部分。