Loop backwards over the table : Table of Char « PL SQL « Oracle PL / SQL






Loop backwards over the table

  
SQL>
SQL> set serveroutput on
SQL>
SQL> DECLARE
  2    TYPE CharTab IS TABLE OF CHAR(1);
  3    v_Characters CharTab :=
  4      CharTab('M', 'a', 'd', 'a', 'm', ',', ' ',
  5              'I', '''', 'm', ' ', 'A', 'd', 'a', 'm');
  6
  7    v_Index INTEGER;
  8  BEGIN
  9    v_Index := v_Characters.LAST;
 10    WHILE v_Index >= v_Characters.FIRST LOOP
 11      DBMS_OUTPUT.PUT(v_Characters(v_Index));
 12      v_Index := v_Characters.PRIOR(v_Index);
 13    END LOOP;
 14
 15    DBMS_OUTPUT.NEW_LINE;
 16  END;
 17  /
madA m'I ,madaM

PL/SQL procedure successfully completed.

SQL>
SQL>

   
  








Related examples in the same category

1.Use table of char as an array
2.FIRST, LAST, NEXT, and PRIOR.
3.Check if next index value exists.
4.Print an indexed element from the array.