Create user type with map : Type Body « Object Oriented Database « Oracle PL / SQL






Create user type with map

 

SQL>
SQL> create or replace
  2  type person as object(
  3   first_name varchar2(100),
  4   last_name varchar2(100) )
  5  /

Type created.

SQL>
SQL>
SQL>
SQL> alter type person
  2  add attribute dob date
  3  cascade not including table data
  4  /

Type altered.

SQL>
SQL> create or replace
  2  type employee as object(
  3   name person,
  4   empno number,
  5   hiredate date,
  6   sal number,
  7   commission number,
  8   map member function convert return number )
  9  /

Type created.

SQL>
SQL> create or replace
  2  type body employee as
  3   map member function convert return number is
  4   begin
  5     return self.empno;
  6   end;
  7  end;
  8  /

Type body created.

SQL>
SQL> drop type employee;

Type dropped.

SQL> drop type person;

Type dropped.

SQL>
SQL>

 








Related examples in the same category

1.Create type body
2.Reference type member function in select statement
3.type attribute accesser
4.Address object
5.Define getter function for object
6.Define ToString method for object type
7.PLS-00588: unqualified instance attribute references allowed only in member methods