René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback
 

Parameter self in member functions/procedures in object oriented PL/SQL

Unlike static member functions/procedures, ordinary member functions/procedures have a self parameter. If this parameter is not explicitly stated, Oracle will implicitly supply such a paramter.
Consider the following object:
create or replace type implicit_self_test as object (

  dummy number, -- prevent PLS-00589: no attributes found in object type

  member procedure proc(param_1 in number, param_2 in varchar2),
  
  member function  func(param_1 in char) return number
);
/

create or replace type body implicit_self_test as

  member procedure proc(param_1 in number, param_2 in varchar2) is begin
    null; -- of course, important stuff done here
  end;
  
  member function func(param_1 in char) return number is begin
    return 42;  -- of course, other important stuff calculated here
  end func;

end;
/
Let's see what arguments this new type's members accept:
break on member_name skip 1

select
  object_name    member_name,
  argument_name,
  in_out
from
  user_arguments
where
      package_name='IMPLICIT_SELF_TEST' -- i.e. object name
  and position <> 0 -- ignore return arguments for now.
order by
  object_name, position;
MEMBER_NAME                    ARGUMENT_NAME                  IN_OUT
------------------------------ ------------------------------ ---------
FUNC                           SELF                           IN
                               PARAM_1                        IN

PROC                           SELF                           IN/OUT
                               PARAM_1                        IN
                               PARAM_2                        IN
As can be seen, both, member functions and member procedures have a parameter called self. This parameter is in out in the case of a procedure while it is merely in in the case of a function.