Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Calling inherited methods

Calling inherited methods

From: Billy Verreynne <vslabs_at_onwe.co.za>
Date: 26 Jun 2004 03:27:48 -0700
Message-ID: <1a75df45.0406260227.76144406@posting.google.com>


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. ;-)

--
Billy
Received on Sat Jun 26 2004 - 05:27:48 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US