Member Methods v13
A member method is a function or procedure that is defined within an object type and can only be invoked through an instance of that type. Member methods have access to, and can change the attributes of, the object instance on which they are operating.
The following object type specification creates the emp_obj_typ
object type:
Object type emp_obj_typ
contains a member method named display_emp
. display_emp
uses a SELF
parameter, which passes the object instance on which the method is invoked.
A SELF
parameter is a parameter whose data type is that of the object type being defined. SELF
always refers to the instance that is invoking the method. A SELF
parameter is the first parameter in a member procedure or function regardless of whether it is explicitly declared in the parameter list.
The following code snippet defines an object type body for emp_obj_typ:
You can also use the SELF
parameter in an object type body. To illustrate how the SELF
parameter would be used in the CREATE TYPE BODY
command, the preceding object type body could be written as follows:
Both versions of the emp_obj_typ
body are completely equivalent.