Postgres Plus Advanced Server Oracle Compatibility Developer's Guide : 8.4 Referencing an Object

Previous PageTable Of ContentsNext Page

Postgres Plus Advanced Server Oracle Compatibility Developer's Guide

 

8.4 Referencing an Object

Once an object variable is created and initialized, individual attributes can be referenced using dot notation of the form:

object.attribute

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

If attribute, itself, is of an object type, then the reference must take the 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 previous anonymous block to display the values assigned to the emp_obj_typ object.

DECLARE
    v_emp          EMP_OBJ_TYP;
BEGIN
    v_emp := emp_obj_typ(9001,'JONES',
        addr_obj_typ('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 is the output from this anonymous block.

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

Previous PageTable Of ContentsNext Page