type attribute accesser : Type Body « Object Oriented Database « Oracle PL / SQL






type attribute accesser

 
SQL>
SQL>
SQL> create or replace
  2  type person as object (
  3   first_name varchar2(100),
  4   last_name varchar2(100),
  5   dob date,
  6   phone varchar2(100),
  7   member function get_last_name return varchar2,
  8   member function get_phone_number return varchar2 )
  9  not final
 10  /

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> create table person_table( p person );

Table created.

SQL>
SQL> select treat( p as person).get_last_name() from person_table p;

no rows selected

SQL>
SQL> drop table person_table;

Table dropped.

SQL>
SQL> drop type person;

Type dropped.

SQL>
SQL>
SQL>
SQL>

 








Related examples in the same category

1.Create type body
2.Create user type with map
3.Reference type member function in select statement
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