Friday, March 9, 2012

PL SQL: How to get subtype out of a supertype table?

Hi all.

I have a supertype 'player_t' and a subtype 'misterx_t'. I have also a table of the supertype with three supertype entities and on subtype entity in it(no table for the subtype). I have inserted them with the regular insert-statement:

insert into player_tab
values
(player_t(detektiv3, 10,10,10));

insert into player_tab
values
(misterx_t(misterx,10,10,10,5,3));

All entities were inserted correctly and if a run a select value(...) ... -command, oracle shows that misterx is of misterx_t and has all attributes (two more than a player)!
But now the problem:
How can I get the subtype out of the supertype table? I only get the supertype part of the subtype entity, but I need the whole entity (with the two more attributes)!
Is there any way to read the whole value?

Thanks for helping!
Greets,
Svengot it myself, thanks.

select TREAT (value(p) as misterx_t) from player_tab p where rolle like 'misterx';

Greets,
Sven

Originally posted by OleS
Hi all.

I have a supertype 'player_t' and a subtype 'misterx_t'. I have also a table of the supertype with three supertype entities and on subtype entity in it(no table for the subtype). I have inserted them with the regular insert-statement:

insert into player_tab
values
(player_t(detektiv3, 10,10,10));

insert into player_tab
values
(misterx_t(misterx,10,10,10,5,3));

All entities were inserted correctly and if a run a select value(...) ... -command, oracle shows that misterx is of misterx_t and has all attributes (two more than a player)!
But now the problem:
How can I get the subtype out of the supertype table? I only get the supertype part of the subtype entity, but I need the whole entity (with the two more attributes)!
Is there any way to read the whole value?

Thanks for helping!
Greets,
Sven

No comments:

Post a Comment