After an object variable is created and initialized, you can reference its individual attributes by using the dot notation of the following form:

object.attribute

where, object is the identifier assigned to the object variable, and attribute is the identifier of an object type attribute.

If the attribute is of an object type, you must reference it in the following form:

object.attribute.attribute_inner

attribute_inner is an identifier belonging to the object type to which attribute references in its definition of object.

The following example expands upon the preceding anonymous block to display the values assigned to the emp_obj_type object:

DECLARE
    v_emp          EMP_OBJ_TYPE;
BEGIN
    v_emp := emp_obj_type(9001,'JONES',
        addr_obj_type('123 MAIN STREET','EDISON','NJ',08817));
    DBMS_OUTPUT.PUT_LINE('Employee No   : ' || v_emp.empno);
    DBMS_OUTPUT.PUT_LINE('Name          : ' || v_emp.ename);
    DBMS_OUTPUT.PUT_LINE('Street        : ' || v_emp.addr.street);
    DBMS_OUTPUT.PUT_LINE('City/State/Zip: ' || v_emp.addr.city || ', ' ||
        v_emp.addr.state || ' ' || LPAD(v_emp.addr.zip,5,'0'));
END;

The following information is the output from this anonymous block:

Employee No   : 9001
Name          : JONES
Street        : 123 MAIN STREET
City/State/Zip: EDISON, NJ 08817

Methods are called in a similar way as attributes.

After an object variable is created and initialized, you can call its member procedures or functions by using the dot notation of the following form:

object.prog_name

where, object is the identifier assigned to the object variable, and prog_name is the identifier of the procedure or function.

You cannot call static procedures or functions by using an object variable. Instead, you can call them by using an object type name.

object_type.prog_name

where, object_type is the identifier assigned to the object type, and prog_name is the identifier of the procedure or function.

The results of the preceding anonymous block can be duplicated by calling the member procedure display_emp.

DECLARE
    v_emp          EMP_OBJ_TYPE;
BEGIN
    v_emp := emp_obj_type(9001,'JONES',
        addr_obj_type('123 MAIN STREET','EDISON','NJ',08817));
    v_emp.display_emp;
END;

The following information is the output from this anonymous block:

Employee No   : 9001
Name          : JONES
Street        : 123 MAIN STREET
City/State/Zip: EDISON, NJ 08817

The following anonymous block creates an instance of dept_obj_type and calls the member procedure display_dept:

DECLARE
    v_dept          DEPT_OBJ_TYPE := dept_obj_type (20);
BEGIN
    v_dept.display_dept;
END;

The following information is the output from this anonymous block:

Dept No    : 20
Dept Name  : RESEARCH

You can directly call the static function defined in dept_obj_type by qualifying it with the object type name as follows:

BEGIN
    DBMS_OUTPUT.PUT_LINE(dept_obj_type.get_dname(20));
END;

RESEARCH