SQL> DECLARE
2 TYPE num_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3 myTable num_tab;
4 v_num NUMBER :=13;
5 BEGIN
6 myTable(1):=1001;
7 myTable(10):=1002;
8 myTable(-10):=1003;
9 myTable(v_num):=1004;
10 dbms_output.put_line(to_char(myTable(100)));
11 END;
12 /
DECLARE
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 10
<topic title="Sample code using exception while accessing an undefined row of an Index-by table">
<code><![CDATA[
SQL> -- Sample code using exception while accessing an undefined row of an Index-by table
SQL> DECLARE
2 TYPE numberTabletype IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3 myTable numberTabletype;
4 v_num NUMBER :=13;
5 BEGIN
6 myTable(1):=1001;
7 myTable(10):=1002;
8 myTable(-10):=1003;
9 myTable(v_num):=1004;
10 dbms_output.put_line(to_char(myTable(100)));
11 EXCEPTION WHEN NO_DATA_FOUND THEN
12 dbms_output.put_line ('Invalid array element ');
13 END;
14 /
Invalid array element
PL/SQL procedure successfully completed.
|