Our Oracle database was recently updated from 12.1.0.2 to 12.2.0.1 + patch set update 20180417.
Ever since the update we are getting the following error when calling a plsql procedure: ORA-21700: object does not exist or is marked for delete
We have narrowed down the issue and it seems to be caused by using the table operator on an associative array defined within the package. All my research shows that what we are doing was introduced in 12.1 and should still work in 12.2.
Below is a simplified version of a procedure that is failing along with the related type definition. It is being called from c# code using managed data access.
Here is the associative array type definition in the package:
TYPE NUMBER_ARRAY IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
Here is a procedure that fails:
PROCEDURE GetReadingStatus(
STATUSID_ARR IN NUMBER_ARRAY,
P_RETURNS OUT SYS_REFCURSOR
)
BEGIN
OPEN P_RETURNS FOR
SELECT * FROM READINGSTATUS rs
WHERE rs.statusID IN (select * from table(STATUSID_ARR));
END;
It runs if the select * from table(STATUSID_ARR)
portion is removed.
Is there an issue with using the table operator on associative arrays in 12.2? Could the issue be stemming from something else?
All my research shows that what we are doing was introduced in 12.1 and should still work in 12.2.
Yes this is true. Prior to Oracle 12c
, you cannot use associate arrays in the scope of SQL
statements within a PLSQL
block. However, Oracle make sure that when it introduces new version, old one doesnot get affected. I tried to test your code and its working fine at my end. Looks issue is somewhere else, might be some issue while using C#. See below demo:
My Oracle Version:
SQL> select * from v$version;
BANNER
------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Table Data:
SQL>SELECT * from TEST;
col
---
1
2
3
Package:
--Package Specification
CREATE OR REPLACE PACKAGE TESTTT
AS
TYPE NUMBER_ARRAY IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
Procedure GetReadingStatus (
STATUSID_ARR IN NUMBER_ARRAY,
P_RETURNS OUT SYS_REFCURSOR
);
END;
/
--Package Body
CREATE OR REPLACE PACKAGE BODY TESTTT
AS
PROCEDURE GetReadingStatus(
STATUSID_ARR IN NUMBER_ARRAY,
P_RETURNS OUT SYS_REFCURSOR
)
Is
BEGIN
OPEN P_RETURNS FOR
SELECT *
FROM TEST
where col IN (SELECT * FROM TABLE(STATUSID_ARR));
END;
END TESTTT;
Calling:
DECLARE
var TESTTT.NUMBER_ARRAY;
v_out sys_refcursor;
num NUMBER;
BEGIN
var(1):= '1';
var(2):= '2';
TESTTT.GetReadingStatus(STATUSID_ARR=>var,
P_RETURNS =>v_out);
Loop
fetch v_out INTO num;
exit WHEN v_out%notfound;
dbms_output.put_line('Return From Procdure--'||num);
end loop;
end;
Output:
Return From Procdure--1
Return From Procdure--2
this question is quite like my situation when I got the same error with 12.2 but not 12.1. I have posted my answer here since that one is using package instead of schema defined type. Maybe this issue can be solve the same way. Just try to add a temp variable of the same type and assign the parameter to it.
来源:https://stackoverflow.com/questions/50821267/error-ora-21700-with-table-operator-after-updating-to-oracle-12-2-from-12-1