Is it possible for an Oracle package (PL/SQL) or object function to return a reference to one of it's attributes, so that in the calling scope an assignment made to that attribute updates the attribute in the object instance or package?
Here is a more involved db<>fiddle, but below is a slimmed down db<>fiddle version.
create or replace type obj as object(
vc varchar2(100)
);
create or replace package pkg as
o obj;
function f return obj;
end;
/
create or replace package body pkg as
function f return obj as
begin
return o;
end;
begin
o := new obj('hello');
end;
/
begin
pkg.f().vc := 'planet'; --PLS-00363: expression 'PKG.F().VC' cannot be used as an assignment target
end;
/
create or replace type parent as object(
o obj
, member function f( self in out nocopy parent ) return obj
, constructor function parent return self as result
);
create or replace type body parent as
member function f( self in out nocopy parent ) return obj as
begin
return self.o;
end;
constructor function parent return self as result as
begin
self.o := new obj('hello');
return;
end;
end;
/
declare
p parent := new parent();
begin
p.f().vc := 'world'; --PLS-00363: expression 'FIDDLE_UEQRJIDDWGWTTMRHYISU.PARENT.F(P).VC' cannot be used as an assignment target
end;
/
Using Oracle 19c Enterprise Edition. Thank you in advance.