09-17-08, 12:16 #1Registered User
- Join Date
- Sep 2008
Unanswered: Return Associative Arrays in a Stored Proc
This is my first time writing these SPs and I can't really see whats wrong with this at the minute.
CREATE OR REPLACE TYPE num_array AS TABLE OF NUMBER; / CREATE OR REPLACE PROCEDURE return_array_test (array_in IN num_array, array_out OUT num_array) AS temp NUMBER; BEGIN FOR i IN 1 .. array_in.count LOOP array_out(i) := array_in(i)*2; END LOOP; END return_array_test; /
set serveroutput on
DECLARE array_in num_array := num_array(1,2,3,4,5); array_out num_array := num_array(1,2,3,4,5); BEGIN return_array_test (array_in, array_out); dbms_output.put_line('Result(s)...'); For i IN 1 .. array_out.count Loop dbms_output.put_line(array_out(i)); END LOOP; END; /
DECLARE * ERROR at line 1: ORA-06531: Reference to uninitialized collection ORA-06512: at "ZORA03_DBO.RETURN_ARRAY_TEST", line 8 ORA-06512: at line 8
This is all test/prototype code to see if I can do this stuff but for my end result I want to return a array of numbers from an SP, this array incidentally I don't know how big it will be (its basically item keys that have failed update for whatever reason).
09-17-08, 12:47 #2Registered User
Provided Answers: 1You can lead some folks to knowledge, but you can not make them think.
- Join Date
- Aug 2003
- Where the Surf Meets the Turf @Del Mar, CA
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Good judgement comes from experience. Experience comes from bad judgement.