Hi,
I'm getting a "Object does not exist or is marked for delete" error when I'm trying to call a PL/SQL function.
I have a function in a package which accepts an array of VARCHARs and returns a ref cursor. It looks like this:
FUNCTION my_function(p_param IN my_array_type) RETURN SYS_REFCURSOR IS
l_result_cursor SYS_REFCURSOR;
BEGIN
OPEN l_result_cursor FOR
SELECT <columns>
FROM <tables>
WHERE <column> IN (SELECT column_value FROM TABLE(p_param));
RETURN l_result_cursor;
END my_function;
There's also the following type declared in the package specification:
TYPE my_array_type IS TABLE OF table.column%TYPE;
When I try to get data back from the function using this code:
DECLARE
l_refcursor sys_refcursor;
TYPE l_type IS RECORD(<columns>);
l_record l_type;
l_array my_package.my_array_type;
BEGIN
--
-- Initialise array.
--
l_array := my_package.my_array_type('One', 'Two');
--
-- Get data.
--
l_refcursor := my_package.my_function(p_param => l_array);
LOOP
FETCH l_refcursor INTO l_record;
EXIT WHEN l_refcursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(l_record.<column>);
END LOOP;
CLOSE l_refcursor;
end;
I get the error. It's complaining on the "OPEN l_result_cursor FOR" line of the function.
Thanks in advance for any suggestions.