ORA-21700 List of Customers can not be used in a CURSOR
993783Feb 27 2013 — edited Mar 13 2013Howdy,
I am trying to use a list of customers (1-Many) generated from a parm passed into a function in a cursor call,
but am getting the "ORA-21700 Object does not exist or is marked for delete".
It will compile, but fails when the cursor is opened. Thoughts on how best to accomplish this.
FUNCTION CUSTOMER(P_CUSTOMER_ID AS NUMBER)
-- DECLARE A TABLE OF NUMBERS
VT_CUSTOMER MASTER_TYPES.CUSTOMER_T;
--=================================================================================
CURSOR CUSTOMER_CUR IS
SELECT CUSTOMER_ID
FROM CUSTOMER_ACTIONS
WHERE CUSTOMER_ID IN (SELECT * FROM TABLE(VT_CUSTOMER));
CUSTOMER_REC CUSTOMER_CUR%ROWTYPE;
--=================================================================================
BEGIN
DBMS_OUTPUT.PUT_LINE('Processing: ' || P_CUSTOMER_ID);
-- Obtain a list of all CUSTOMERs related to request
SELECT CUSTOMER_ID BULK COLLECT
INTO VT_CUSTOMER
FROM CUSTOMER_TBL
START WITH CUSTOMER_ID = P_CUSTOMER_ID
CONNECT BY CUSTOMER_ID = PRIOR MOVED_FROM_CUSTOMER;
IF VT_CUSTOMER.COUNT = 0 THEN
RAISE_APPLICATION_ERROR(-20100, TO_CHAR(P_CUSTOMER_ID) || ' NOT FOUND');
END IF;
FOR CUSTOMER_REC IN CUSTOMER_CUR LOOP
DBMS_OUTPUT.PUT_LINE('CUSTOMER ACTION: ' || CUSTOMER_REC.CUSTOMER_ID);
END LOOP;
END;