This content has been marked as final. Show 4 replies
I'm not sure I follow all of what you are trying to achieve but I think I have a couple ideas around it.
You can get a ref to a local object like this:
my_obj my_obj_type := my_obj_type (null);
my_obj_ref ref my_obj_type;
select ref(my_obj) into my_obj_ref from dual;
I think what you want is a member function that returns a reference to itself.
I would expect that you could try something like the above within the member function and return the resulting ref. I have not tried this though.
My reading of the docs was that REF expects a correlation variable, not an object. In other words, it needs to be in a table somewhere. :-(
ie. DEREF(REF(i)) == object != i
But I will try your suggestion!
If you are using a PK-REF based object view or table, you can use the MAKE_REF function to get a REF to an object that is not yet persistently stored.
If you are using system-generated OIDs you cannot get a REF until it is stored in a table.
if you use object views instead of object tables, it's as easy to construct a 'self-reference' attribute as an other REF attribute, use MAKE_REF:
Hope this helps.
create or replace view V_My_View of TMyObject with object identifier (key1, key2, ...) as select t.key1 , t.key2 , ... , make_ref(V_My_View, t.key1, t.key2, ...) as selfRef , ... from T_My_Table t where ...