Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> how to write a function that returns a dataset
Hello,
I'm quite new to oracle and probably there is no way to do what I want to do.
I want to write a function that gets one input parameter and returns a dataset.
Until now I have written a function that returns the date of the easter Sunday (one value / see at th bottom of the posting).
THIS one I can query as follows:
SELECT geteastersunday(2007) FROM DUAL
Now I want to write another function that uses this one to calculate all banking holidays that depend on this date and return it as a recordset.
Probably my attempt is totally wrong an I have to tackle this problem on a completely different approach.
I'm open to any suggestions.
Please excuse my bad English, I'm not a native speaker ;-)
Thanks in advance
Ray
RETURN DATE
IS
yaer INTEGER; a INTEGER; b INTEGER; c INTEGER; d INTEGER; e INTEGER; f INTEGER;
BEGIN
yaer := input;
IF yaer = 0
THEN
yaer := TO_CHAR (SYSDATE, 'yyyy');
END IF;
a := yaer MOD 19; b := yaer / 100; c := (8 * b + 13) / 25 - 2; d := b - (yaer / 400) - 2; e := (19 * (yaer MOD 19) + ((15 - c + d) MOD 30)) MOD 30;
IF e = 28
THEN
IF a > 10 THEN e := 27; END IF;
RETURN TO_DATE('' || yaer || '0301', 'YYYYMMDD') + f;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
RAISE;
END geteastersunday;
/
Received on Wed Jul 18 2007 - 11:58:17 CDT
![]() |
![]() |