SQL>
SQL> create or replace
2 type person as object (
3 first_name varchar2(100),
4 last_name varchar2(100),
5 member function get_last_name return varchar2,
6 member function get_phone_number return varchar2 )
7 not final
8 /
Type created.
SQL>
SQL>
SQL> create or replace
2 type body person as
3 member function get_last_name return varchar2 is
4 begin
5 return self.last_name;
6 end;
7 member function get_phone_number return varchar2 is
8 begin
9 return self.phone;
10 end;
11 end;
12 /
Warning: Type Body created with compilation errors.
SQL>
SQL>
SQL> create table person_table( p person );
Table created.
SQL>
SQL>
SQL> insert into person_table values ( person( 'Sean', 'Viper' ));
1 row created.
SQL>
SQL> select * from person_table;
P(FIRST_NAME, LAST_NAME)
--------------------------------------------------------------------------------
person('Sean', 'Viper')
SQL>
SQL> drop table person_table;
Table dropped.
SQL>
SQL>
SQL> drop type person;
Type dropped.
|