Oracle
 sql >> Database >  >> RDS >> Oracle

In Oracle, come posso verificare il tipo di oggetto utilizzato da una gerarchia di tipi di oggetto?

Puoi controllare il tipo di un oggetto usando sys.anydata :

create or replace function which_type
    ( p_fv fv )
    return varchar2
as
begin
    return sys.anydata.gettypename(sys.anydata.convertobject(p_fv));
end which_type;

Prova:

create or replace type number_array as table of number;
create or replace type integer_array as table of integer;

create or replace type fv as object (
   idno           number)
not final;
/

create type fv_integer under fv (
   features integer_array)
   not final;
/

create type fv_number under fv (
   features number_array)
   not final;
/

create table fv_test (my_fv fv);

insert into fv_test values (fv(1));
insert into fv_test values (fv_integer(1, integer_array(1)));
insert into fv_test values (fv_number(1, number_array(1)));

select which_type(my_fv) from fv_test;

WHICH_TYPE(MY_FV)
-------------------------
WILLIAM.FV
WILLIAM.FV_INTEGER
WILLIAM.FV_NUMBER

3 rows selected.