--INDEX BY Pl/sql数组
SET SERVEROUTPUT ON
DECLARE
TYPE NumberTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
v_Numbers NumberTab;
BEGIN
FOR v_Count in 1..10 LOOP
v_Numbers(v_Count) := v_Count * 10;
END LOOP;
DBMS_OUTPUT.put_line('Table elements: ');
FOR v_Count IN 1..10 LOOP
DBMS_OUTPUT.put_line(' v_Numbers('|| v_Count||'): '||v_Numbers(v_Count));
END LOOP;
BEGIN
DBMS_OUTPUT.put_line('v_Numbers(11): '|| v_Numbers(11));
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.put_line('No data found reading v_Numbers(11)!');
END;
END;
--INDEX BY Pl/sql数组002
SET SERVEROUTPUT ON
declare
type T_customerTab is table of t_customer%rowtype index by binary_integer;
t_customers T_customerTab;
begin
select * into t_customers(1) from t_customer where rownum = 1;
DBMS_OUTPUT.put_line( 'customer_name: '||t_customers(1).customer_id || ' customer_name: '||t_customers(1).customer_name);
end;