René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

not final [Oracle PL/SQL]

The not final clause can either be specified for an object type, for a member procedure/function or for a static member.

not final object types

A final object type is a type from which cannot be derived
Here's a final and a non-final type:
create type this_type_is_NOT_final as object (
  
  foo number,

  member function mult(p in number) return number

) not final;
/

create type this_type_IS_final as object (
  
  foo number,

  member function mult(p in number) return number

) final;
/
Here are their type bodies:
create or replace type body this_type_is_NOT_final as
  member function mult(p in number) return number is begin
    return foo * p;
  end mult;
end;
/

create or replace type body this_type_IS_final as
  member function mult(p in number) return number is begin
    return foo * p;
  end mult;
end;
/

Trying to derive

The following type can be derived because the base type is not final.
create or replace type derived_from_NOT_final under this_type_is_NOT_final (
  member procedure bar
);
/
The following type can not be derived because the base type is final.
create or replace type derived_from_FINAL under this_type_IS_final (
  member procedure bar
);
/
Trying to derive from a final type gives a PLS-00590: attempting to create a subtype UNDER a FINAL type.

not final member procedures/functions

Here's a type with a final and a non-final member function:
create type some_base_type as object (
  
  foo number,

  not final member function NOT_FINAL_func(p in number) return number,
  final     member function FINAL_func    (p in number) return number
) not final;
/
Here is it's body:
create or replace type body some_base_type as

  final     member function FINAL_func(p in number) return number is begin
    return foo + p;
  end FINAL_func;

  not final member function NOT_FINAL_func(p in number) return number is begin
    return foo - p;
  end NOT_FINAL_func;

end;
/

Trying to derive and override

A member function (or procedure) can be overriden if it is declared not final in the base class (which is the case here):
create or replace type some_derived_type_1 under some_base_type (
  overriding member function NOT_FINAL_func(p in number) return number
);
/
The following does not work because final member functions (or procedures) cannot be overriden:
create or replace type some_derived_type_2 under some_base_type (
  overriding member function FINAL_func(p in number) return number
);
/
It results in a PLS-00637: FINAL method cannot be overriden or hidden.