Error using BULK Collect with RECORD TYPE
AJ.MOct 12 2010 — edited Oct 12 2010hello
I have written a simple Procedure by declaring a record type & then making a variable of NESTED Table type.
I then select data using BULK COLLECT & tryin to access it through a LOOP.....Getting an ERROR.
------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
IS
TYPE rec_type IS RECORD (
emp_id VARCHAR2(20),
level_id NUMBER
);
TYPE v_rec_type IS TABLE OF rec_type;
BEGIN
SELECT employee_id, level_id
BULK COLLECT INTO v_rec_type
FROM portfolio_exec_level_mapping
WHERE portfolio_execp_id = 2851852;
FOR indx IN v_rec_type.FIRST..v_rec_type.LAST
LOOP
dbms_output.put_line('Emp -- '||v_rec_type.emp_id(indx)||' '||v_rec_type.level_id(indx));
END LOOP;
END;
-----------------------------------------------------------------------------------------------------------------------------------
Below are the ERROR's i am getting ....
- Compilation errors for PROCEDURE DOMRATBDTESTUSER.SP_TEST_BULKCOLLECT
Error: PLS-00321: expression 'V_REC_TYPE' is inappropriate as the left hand side of an assignment statement
Line: 15
Text: FROM portfolio_exec_level_mapping
Error: PL/SQL: ORA-00904: : invalid identifier
Line: 16
Text: WHERE portfolio_execp_id = 2851852;
Error: PL/SQL: SQL Statement ignored
Line: 14
Text: BULK COLLECT INTO v_rec_type
Error: PLS-00302: component 'FIRST' must be declared
Line: 19
Text: LOOP
Error: PL/SQL: Statement ignored
Line: 19
Text: LOOP
------------------------------------------------------------------------------------------------
PLZ Help.