DECLARE -- TYPE typ_name IS TABLE OF datentyp [NOT NULL] -- INDEX BY {BINARY_INTEGER| VARCHAR(x)};
TYPE numarray IS
TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
l_data numarray;
BEGIN
l_data(1) := 'Marco';
l_data(2) := 'Hans';
l_data(3) := 'Andrea'; --l_data(4) := 'Andrea'; =>ORA-22160: Element bei Index [3] nicht vorhanden
FOR i IN 1..l_data.count LOOP
dbms_output.put_line(l_data(i));
END LOOP;
END;
/
DECLARE -- TYPE typ_name IS TABLE OF datentyp [NOT NULL] -- INDEX BY {BINARY_INTEGER| VARCHAR(x)};
TYPE numarray IS
TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
l_data numarray;
BEGIN
l_data(1) := 'Marco';
l_data(2) := 'Hans';
l_data(3) := 'Andrea'; --l_data(4) := 'Andrea'; =>ORA-22160: Element bei Index [3] nicht vorhanden
FORALL i IN 1..l_data.count
INSERT INTO t
SELECT
l_data(i)
FROM
dual
WHERE
l_data(i) IS NOT NULL;
END;
/
SELECT * FROM t;