Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL
Hi !
>I am trying to write a PL/SQL to generate year-begin dates for the past 10
...
Why You are using CURSOR ? Look at this
DECLARE
YEARS INTEGER := 10;
PRIOR_YEAR DATE := TRUNC(TO_DATE(SYSDATE),'YEAR');
PS_REC DATE;
BEGIN
DBMS_OUTPUT.enable();
LOOP
PS_REC := TRUNC(PRIOR_YEAR - 1,'YEAR');
EXIT WHEN YEARS = 0;
YEARS := YEARS - 1;
PRIOR_YEAR := PS_REC;
DBMS_OUTPUT.put_line(PRIOR_YEAR);
PRIOR_YEAR := PRIOR_YEAR - 1;
END LOOP;
END;
Received on Tue Mar 07 2000 - 00:00:00 CST
![]() |
![]() |