SQL codecreate or replace function timecoverbegin(outbegintime IN DATE,
outendtime IN DATE,
inbegintime IN DATE,
inendtime IN DATE)
RETURN date
as
tempTbl varchar2(300);
result date;
begin
tempTbl:=' create global temporary table tempTbl
(
tempdate date
) on commit delete rows ';
EXECUTE IMMEDIATE tempTbl;
insert into tempTbl(tempdate) values(outbegintime);
insert into tempTbl(tempdate) values(outendtime);
insert into tempTbl(tempdate) values(inbegintime);
insert into tempTbl(tempdate) values(inendtime);
select tempdate into result from tempTbl order by tempdate;
return result;
end timecoverbegin
;
/