Error Pl/SQL collection. [message #366178] |
Fri, 12 December 2008 00:17  |
trivendra
Messages: 211 Registered: October 2007 Location: Phoenix
|
Senior Member |
|
|
Hello Everyone.
I am doing some POC for table fucntion. When I tried to execute the following package I found the following exception.
ORA-06533: Subscript beyond count
ORA-06512: at "FUN_TAB_TEST", line 13
The Package Code is like
CREATE OR REPLACE PACKAGE fun_tab_test
IS
TYPE rec1 IS RECORD (
seq NUMBER (10)
);
TYPE tab1 IS TABLE OF rec1;
FUNCTION test1
RETURN tab1 PIPELINED;
END;
/
CREATE OR REPLACE PACKAGE BODY fun_tab_test
IS
FUNCTION test1
RETURN tab1 PIPELINED
IS
v_tab1 tab1 := tab1 ();
num NUMBER (10) := 1;
BEGIN
FOR j IN (SELECT LEVEL lvl
FROM DUAL
CONNECT BY LEVEL <= 10)
LOOP
v_tab1 (num).seq := j.lvl;
num := num + 1;
PIPE ROW (v_tab1 (num));
END LOOP;
RETURN;
END;
END;
/
SELECT * FROM TABLE (fun_tab_test.test1);
ORA-06533: Subscript beyond count
ORA-06512: at "FUN_TAB_TEST", line 13
Please correct me where I am wrong.
Thanks
Trivendra
|
|
|
|
|
Re: Error Pl/SQL collection. [message #366191 is a reply to message #366178] |
Fri, 12 December 2008 01:17   |
trivendra
Messages: 211 Registered: October 2007 Location: Phoenix
|
Senior Member |
|
|
Thanks Kevin/Michel,
Great help, Little logical mistake. I have changed the code to..
LOOP
v_tab1.EXTEND (num);
v_tab1 (num).seq := j.lvl;
PIPE ROW (v_tab1 (num));
num := num + 1;
END LOOP;
Kevin,
Great Example and illustration.
Here at
Will raise the same error as I have got.
Thanks
Trivenda
|
|
|
|
|