Тази грешка:
ORA-06531: Reference to uninitialized collection
означава, че имате колекция, която не е инициализирана, преди да я използвате, например:
SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE TYPE t_employee AS OBJECT(
2 id number,
3 name VARCHAR2(300),
4 CONSTRUCTOR FUNCTION t_employee RETURN SELF AS RESULT
5* )
SQL> /
Type created.
SQL> ed
Wrote file afiedt.buf
1* CREATE OR REPLACE TYPE t_employees AS TABLE OF t_employee
SQL> /
Type created.
SQL> ed
Wrote file afiedt.buf
1 DECLARE
2 l_emp t_employee;
3 l_emps t_employees;
4 BEGIN
5 for i in (SELECT employee_id, first_name
6 FROM employees)
7 loop
8 l_emp := t_employee(i.employee_id, i.first_name);
9 l_emps.extend();
10 l_emps(l_emps.COUNT) := l_emp;
11 end loop;
12 DBMS_OUTPUT.put_line(l_emps(4).name);
13* END;
SQL> /
DECLARE
*
ERROR at line 1:
ORA-06531: Reference to uninitialized collection
ORA-06512: at line 9
Както можете да видите, имам ORA-06531
грешка, това е защото не съм инициализирал l_emps
променлива, трябва да добавя l_emps := t_employees();
:
SQL> ed
Wrote file afiedt.buf
1 DECLARE
2 l_emp t_employee;
3 l_emps t_employees;
4 BEGIN
5 l_emps := t_employees();
6 for i in (SELECT employee_id, first_name
7 FROM employees)
8 loop
9 l_emp := t_employee(i.employee_id, i.first_name);
10 l_emps.extend();
11 l_emps(l_emps.COUNT) := l_emp;
12 end loop;
13 DBMS_OUTPUT.put_line(l_emps(4).name);
14* END;
SQL> /
David
PL/SQL procedure successfully completed.
Така че погледнете източниците на всички тези PL/SQL процедури, проблемът е в тях.