Using TREAT function on dangling REF in PL/SQL raises uncatchable ORA-21700 exception
The following code demonstrates the situation summarized by the subject line:
create or replace type TMyObject
is object
(
id integer
)
/
create or replace view V_My_Object
of TMyObject
with object identifier (id)
as
select new TMyObject(1234)
from DUAL
/
set serveroutput on
declare
valid_id integer := 1234;
invalid_id integer := 1000;
r ref TMyObject;
i TMyObject;
begin
--
-- Notice that using UTL_REF.Select_Object on the invalid REF raises ORA-21700, but that the exception is caught
--
select make_ref(V_My_Object, valid_id)
into r
from DUAL;
begin
UTL_REF.Select_Object(r, i);
dbms_output.put_line(i.id);