Member methods v16
A member method is a function or procedure that's defined in an object type and can be invoked only through an instance of that type. Member methods have access to, and can change the attributes of, the object instance on which they're operating.
This object type specification creates the
emp_obj_typ object type:
emp_obj_typ contains a member method named
display_emp uses a
SELF parameter, which passes the object instance on which the method is invoked.
SELF parameter is a parameter whose data type is that of the object type being defined.
SELF always refers to the instance that's invoking the method. A
SELF parameter is the first parameter in a member procedure or function regardless of whether it's explicitly declared in the parameter list.
The following code defines an object type body for
You can also use the
SELF parameter in an object type body. Using the
SELF parameter in the
CREATE TYPE BODY command, you can write the same object type body as follows:
Both versions of the
emp_obj_typ body are equivalent.