The following code uses a nested table with six elements to show how to use PRIOR and NEXT methods.
SQL> SQL> DECLARE-- w w w . j a va 2s . c o m 2 TYPE IntegerListType IS TABLE OF NUMBER; 3 nt IntegerListType := IntegerListType(18, NULL, 36, 45, 54, 63); 4 5 BEGIN 6 nt.DELETE(4); 7 DBMS_OUTPUT.PUT_LINE('nt(4) was deleted.'); 8 FOR i IN 1..7 LOOP 9 DBMS_OUTPUT.PUT('nt.PRIOR(' || i || ') = '); print(nt.PRIOR(i)); 10 DBMS_OUTPUT.PUT('nt.NEXT(' || i || ') = '); print(nt.NEXT(i)); 11 END LOOP; 12 END; 13 / nt(4) was deleted. nt.PRIOR(1) = NULL nt.NEXT(1) = 2 nt.PRIOR(2) = 1 nt.NEXT(2) = 3 nt.PRIOR(3) = 2 nt.NEXT(3) = 5 nt.PRIOR(4) = 3 nt.NEXT(4) = 5 nt.PRIOR(5) = 3 nt.NEXT(5) = 6 nt.PRIOR(6) = 5 nt.NEXT(6) = NULL nt.PRIOR(7) = 6 nt.NEXT(7) = NULL PL/SQL procedure successfully completed. SQL>