表:given_dates
BOOK_DT1 BOOK_DT2 USERID
--------- --------- --------------------
22-SEP-17 12-NOV-17 rahul
20-JAN-17 10-FEB-17 ABC
02-MAR-17 10-MAR-17 ZXC
13-NOV-17 14-NOV-17 tth
当我插入一行时:
insert into given_dates('01-JAN-2017','05-JAN-2017','AAA');
应调用触发器将细节插入另一个表中,如下所示
table:all_dates_used
表:given_dates
DATET1 USERID
--------- ---------
01-JAN-17 AAA
02-JAN-17 AAA
03-JAN-17 AAA
04-JAN-17 AAA
05-JAN-17 AAA
答案 0 :(得分:1)
如果我理解你的需要,这可能是一种方式:
int[] ints = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
ints = ints.Select((x, index) => new { Value = x, Index = index })
.OrderBy(tuple => (tuple.Index >= start && tuple.Index <= stop) ? random.Next(start, stop) : tuple.Index)
.Select(tuple => tuple.Value)
.ToArray();
<强>测试强>
create or replace trigger insertDates
after insert on given_dates
for each row
begin
insert into all_dates_used(DATET1 , USERID)
select :new.BOOK_DT1 + level -1, :new.USERID
from dual
connect by :new.BOOK_DT1 + level -1 <= :new.BOOK_DT2;
end;