Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Collections
 

An example of COUNT method

SQL> DECLARE   2    TYPE numberTabletype IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;   3    myTable numberTabletype;   4  BEGIN   5    FOR idx IN 1..10 LOOP   6      myTable(idx):=(2**idx)+1;   7    END LOOP;   8   9    FOR idx IN 1..myTable.COUNT LOOP  10      dbms_output.put_line(to_char(myTable(idx)));  11    END LOOP;  12  13  END;  14  / 3 5 9 17 33 65 129 257 513 1025 PL/SQL procedure successfully completed.