Object Oriented Oracle PLSQL Tutorial

SQL>  CREATE OR REPLACE TYPE address2 AS OBJECT
  2              (line1 VARCHAR2(20),
  3               line2 VARCHAR2(20),
  4               city VARCHAR2(20),
  5               state_code VARCHAR2(2),
  6               zip VARCHAR2(13),
  7               country VARCHAR(3),
  8    CONSTRUCTOR FUNCTION address2(addressLine1 VARCHAR2,
  9                  addressLine2 VARCHAR2,
 10                  address_city VARCHAR2,
 11                  address_state VARCHAR2,
 12                  address_zip VARCHAR2)
 13    RETURN SELF AS RESULT);
 14  /
Type created.
SQL> CREATE OR REPLACE TYPE BODY address2 IS
  2    CONSTRUCTOR FUNCTION address2(addressLine1 VARCHAR2,
  3                  addressLine2 VARCHAR2,
  4                  address_city VARCHAR2,
  5                  address_state VARCHAR2,
  6                  address_zip VARCHAR2)
  7    RETURN SELF AS RESULT
  8    IS
  9    BEGIN
 10      SELF.line1 :=addressLine1;
 11      SELF.line2 :=addressLine2;
 12      SELF.city :=address_city;
 13      SELF.state_code :=address_state;
 14      SELF.zip :=address_zip;
 15      SELF.country :='USA';
 16      RETURN;
 17    END;
 18  END;
 19  /
Type body created.
SQL> declare
  2    addressValue address2;
  3  begin
  4    addressValue :=address2('Suite 288','S Street','San Jose','CA','00000');
  5
  6    dbms_output.put_line(addressValue.line1);
  7
  8    dbms_output.put_line(addressValue.line2);
  9
 10    dbms_output.put_line(addressValue.city||', '||addressValue.state_code||' '||addressValue.zip);
 11
 12    dbms_output.put_line(addressValue.country);
 13  end;
 14  /
Suite 288
S Street
San Jose, CA 00000
USA
PL/SQL procedure successfully completed.