PL/SQL (MOSC)

MOSC Banner

Hierarchical Tree

edited Dec 15, 2010 11:17PM in PL/SQL (MOSC) 11 commentsAnswered ✓
I have the following tables (simplified for effect).
 
CREATE TABLE "CALCULATION"
   (    "ID" NUMBER(10,0),
        "ROOT_ELEMENT_ID" NUMBER(10,0)
   ) ;
 
CREATE TABLE "CALCULATION_ELEMENT"
   (    "ID" NUMBER(10,0),
        "NAME" VARCHAR2(255 CHAR ),
        "PARENT_ID" NUMBER(10,0)
   ) ;
 
ALTER TABLE "CALCULATION" ADD CONSTRAINT "FK_CALC_CALC_ELEM" FOREIGN KEY ("ROOT_ELEMENT_ID")
          REFERENCES "CALCULATION_ELEMENT" ("ID") ON DELETE CASCADE ENABLE;
 
ALTER TABLE "CALCULATION_ELEMENT" ADD CONSTRAINT "FK_CALC_ELEM_PARENT" FOREIGN KEY ("PARENT_ID")
          REFERENCES "CALCULATION_ELEMENT" ("ID") ON DELETE CASCADE ENABLE;
 
 
What I would like to do is create a query/view that allows me to select all calculation_elements for a particular calculation id. Ie the calculation points me to the top of the tree of calculation_elements. The results should look something like this:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center