Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Calling inherited methods
The best way to explain what I want to do is to give a pseudo code
example.
create type TAnimal
(
public data
constructor TAnimal
{
do animal_stuff
}
)
create type TCow subclass of TAnimal
(
public data
constructor TCow
{
// call parent class constructor TAnimal() / which will result in "do animal_stuff" inherited Create do cow_stuff
I would like to do this in Oracle. Did RTFM'ing of the OO Relational
guide for Developers.. hacked away in PL/SQL.. asked on Metalink
(which resulted in a spontanous round of indefference to my posting
;-).. nothing yet on whether this is supported or possible in Oracle.
(does not seem to be the case - but confirmation would be nice).
The reason for wanting to do a "inherited Create" (Delphi syntax btw) is that there are often private/protected/public properties is set or initialised in the constructor. Failing to do an "inherited Create" can thus cause all kinds of problems when you subclass that class as the inherited properties are not initialised and set.
There are ways around this.. I think. But that will require a unique method per class that can be called direct in subclasses and must be the only method call in that class's constructor.
Something like (have not yet tried this, but it should work):
create type TAnimal
(
public data
method Animal_Stuff
{
do animal_constructing
}
constructor TAnimal
{
Animal_stuff()
}
)
create type TCow subclass of TAnimal
(
public data
method Cow_Stuff
{
do cow_constructing
}
constructor TCow
{
Animal_Stuff() Cow_Stuff()
However, this is pretty much a hack.
The usual non-null pointers, blondes, and beers will be much appreciated. ;-)
-- BillyReceived on Sat Jun 26 2004 - 05:27:48 CDT
![]() |
![]() |