How to get rid of "ORA-22881: dangling REF" error on :new.OBJECT_VALUE?
384296Oct 15 2008 — edited Oct 18 2008Hi,
I'm having trouble with a "ORA-22881: dangling REF" error against :new.OBJECT_VALUE when a trigger executes.
Here is the initial trigger:
create or replace TRIGGER "CSHEET_UPDATE"
BEFORE UPDATE ON "CSHEET" FOR EACH ROW
BEGIN
SELECT
updateXML(
:new.OBJECT_VALUE,
'/Csheet/METADATA/MODIFIED_DATE/text()', to_char(SYSDATE, 'YYYY-MM-DD') || 'T' || to_char(SYSDATE, 'HH:MI:SS')
)
INTO :new.OBJECT_VALUE FROM dual;
END;
And this is the error I get with even a simple UPDATE:
BEGIN
UPDATE CSHEET SET OBJECT_VALUE = OBJECT_VALUE WHERE rownum = 1;
COMMIT;
END;
Error report:
ORA-22881: dangling REF
ORA-06512: at "LNC.CSHEET_UPDATE", line 5
ORA-04088: error during execution of trigger 'LNC.CSHEET_UPDATE'
ORA-06512: at line 2
22881. 00000 - "dangling REF"
*Cause: The object corresponding to the REF that was accessed does not
exist.
*Action: Ensure that the REF value is pointing to an existing object.
However, if I add a schemavalidate() call at the beginning of the trigger then the error disappears.
New trigger:
create or replace TRIGGER "CSHEET_UPDATE"
BEFORE UPDATE ON "CSHEET" FOR EACH ROW
BEGIN
:new.OBJECT_VALUE.schemavalidate();
SELECT
updateXML(
:new.OBJECT_VALUE,
'/Csheet/METADATA/MODIFIED_DATE/text()', to_char(SYSDATE, 'YYYY-MM-DD') || 'T' || to_char(SYSDATE, 'HH:MI:SS')
)
INTO :new.OBJECT_VALUE FROM dual;
END;
Is there another way, besides using ":new.OBJECT_VALUE.schemavalidate();", to correct the :new.OBJECT_VALUE dangling REF issue?
Thanks
Keith