SQL>
SQL> set serverout on
SQL>
SQL> create or replace
2 type person as object (
3 last_name varchar2(100),
4 phone 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 /
Type body created.
SQL>
SQL>
SQL>
SQL> declare
2 l_person person;
3 begin
4 l_person := person( 'C', 'B' );
5 dbms_output.put_line( l_person.last_name );
6 end;
7 /
C
PL/SQL procedure successfully completed.
|