Declare
type v_year_arr is varray(100) of emps%rowtype;
v_deptid emps.department_id%type :=90;
v_rem1 number(5,2);
v_rem2 number(5,2);
v_rem3 number(5,2);
v_year v_year_arr;
Begin
select * bulk collect into v_year from emps where department_id = v_deptid;
v_rem1 := MOD(v_year.yof,4);
v_rem2 := MOD(v_year.yof,100);
v_rem3 := MOD(v_year.yof,400);
for i..v_year loop
If (v_rem1=0 and v_rem2=0 and v_rem3=0)
then
DBMS_OUTPUT.PUT_LINE('Leap year :'||v_year.yof);
else
DBMS_OUTPUT.PUT_LINE('Not a Leap year :'||v_year.yof)
End if;
end loop;
end;
getting ORA-06550 error
70 Views Asked by user2664165 At
1
I think you'd be better off writing this using a cursor FOR loop, as in:
This eliminates the potential problem of having more than 100 rows returned by the
SELECT...BULK COLLECT INTO...
statement. I also took the liberty of correcting your leap year determination.Share and enjoy.