Classes define attributes and methods.
Attributes are used to store an object's state, and methods are used to model an object's behaviors.
You create an object type using the CREATE [OR REPLACE] TYPE statement.
SQL>
SQL> CREATE Or Replace TYPE AddressType AS OBJECT (
2 street VARCHAR2(15),
3 city VARCHAR2(15),
4 state CHAR(2),
5 zip VARCHAR2(5)
6 );
7 /
SQL> CREATE OR REPLACE TYPE address AS OBJECT
2 (line1 VARCHAR2(20),
3 line2 VARCHAR2(20),
4 city VARCHAR2(20),
5 state_code VARCHAR2(2),
6 zip VARCHAR2(13));
7 /
Type created.
SQL>
SQL> DECLARE
2 off_add address :=address('19 J','R Rd','Vancouver','NJ','00000');
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE(off_add.line1||' '||off_add.line2);
5 DBMS_OUTPUT.PUT_LINE(off_add.city||', '||off_add.state_code||' '||off_add.zip);
6 END;
7 /
19 J R Rd
Vancouver, NJ 00000
PL/SQL procedure successfully completed.
SQL>
SQL>