Number Table by BINARY_INTEGER : Table of number « PL SQL « Oracle PL / SQL






Number Table by BINARY_INTEGER

    
SQL>
SQL> set serveroutput on
SQL>
SQL> DECLARE
  2    TYPE NumberTab IS TABLE OF NUMBER
  3      INDEX BY BINARY_INTEGER;
  4    v_Numbers NumberTab;
  5  BEGIN
  6    FOR v_Count IN 1..10 LOOP
  7      v_Numbers(v_Count) := v_Count * 10;
  8    END LOOP;
  9
 10    DBMS_OUTPUT.PUT_LINE('Table elements: ');
 11    FOR v_Count IN 1..10 LOOP
 12      DBMS_OUTPUT.PUT_LINE('  v_Numbers(' || v_Count || '): ' ||
 13                           v_Numbers(v_Count));
 14    END LOOP;
 15
 16    BEGIN
 17      DBMS_OUTPUT.PUT_LINE('v_Numbers(11): ' || v_Numbers(11));
 18    EXCEPTION
 19      WHEN NO_DATA_FOUND THEN
 20         DBMS_OUTPUT.PUT_LINE(
 21           'No data found reading v_Numbers(11)!');
 22    END;
 23  END;
 24  /
Table elements:
v_Numbers(1): 10
v_Numbers(2): 20
v_Numbers(3): 30
v_Numbers(4): 40
v_Numbers(5): 50
v_Numbers(6): 60
v_Numbers(7): 70
v_Numbers(8): 80
v_Numbers(9): 90
v_Numbers(10): 100
No data found reading v_Numbers(11)!

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>

   
    
    
  








Related examples in the same category

1.use virtual table in PL/SQL block
2.TYPE NumbersTab IS TABLE OF NUMBER.
3.Legal and illegal table assignments.
4.Declare an index-by table variable to hold the employee records that we read in
5.Clear the salaries table by assigning the empty version to it
6.assignments to nested table elements, and the ORA-6533 error.
7.Use nested table constructors.
8.NULL key value in an index-by table
9.Try to insert elements 3 through 5
10.Use the Oracle10g Collection API COUNT method against an element.
11.Use the Oracle10g Collection API DELETE method against a set of elements.
12.Use the Oracle10g Collection API EXISTS method against an element.
13.Use the Oracle10g Collection API EXTEND method against an element.
14.Use the Oracle10g Collection API FIRST and LAST methods against a collection.
15.A nested table of a scalar variable:
16.Associate array: varchar2 to number map
17.Delete a elements from 2, 3 and 4.
18.Delete element 2.
19.number_list.EXTEND(2): Add two null value members at the end of the list.
20.number_list.EXTEND(3,4): Add three members at the end of the list and copy the contents of item 4
21.EXISTS method
22.Use variable.Last to get the last element
23.Extend space in number list.
24.FIRST method returns the lowest subscript value used in a collection
25.Table of number index by varchar2