Monday, April 5, 2010

ORA-22816: unsupported feature with RETURNING clause

Of course...last night I remembered what it was about using the RETURNING clause across database links.

I was trying to prove a point about APEX across database links but messed up my demo.

If the code lives on the database with APEX installed, then you can't use database links with the RETURNING clause.

Now I create the code in my schema referencing the objects using database links.
CREATE SEQUENCE sq_t
START WITH 100
INCREMENT BY 1
CACHE 10
NOCYCLE;

CREATE OR REPLACE
FUNCTION create_t
( p_first_name IN VARCHAR2,
p_last_name IN VARCHAR2 ) RETURN NUMBER
IS
l_id NUMBER;
BEGIN
INSERT INTO t@my_application
( id,
first_name,
last_name )
VALUES
( sq_t.nextval,
p_first_name,
p_last_name )
RETURNING id INTO l_id;

RETURN l_id;
END create_t;
/
show errors
The function compiles normally, but when you try and run it...
CJUSTICE@TESTING>var c number;
CJUSTICE@TESTING>exec :c := create_t( 'chet', 'justice' );
BEGIN :c := create_t( 'chet', 'justice' ); END;

*
ERROR at line 1:
ORA-22816: unsupported feature with RETURNING clause
ORA-06512: at "CJUSTICE.CREATE_T", line 7
ORA-06512: at line 1
Voila!

No comments: