Reference object type attribute in PL/SQL block
SQL>
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> declare
2
3 l_person person;
4 begin
5 l_person := person( 'A','sean');
6 dbms_output.put_line( l_person.last_name );
7 end;
8 /
A
PL/SQL procedure successfully completed.
Related examples in the same category