SQL query of a tree structure

  • From: Marc Demlenne <marc.demlenne@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Wed, 27 Apr 2005 21:39:51 +0200

Hi all,

I'm searching help to solve the following problem :

I have to query an ORACLE db to get a tree structure which is stored inside=
.
The DB already exists, and i'm not able to modify its structure. I
could only add supplementary columns if necessary.

The trees (which represents a decisional tree) is stored in multiple
tables. We have one for root, and one table by type of decision
criterions or by leaf. On each record of each tree table, we have in
addition to usefull parameters proper to each criterion, 4 "tree
specific" ones which gives respectively the TYPE and NODEID of
previous and next node in the tree.
The 'custom columns' can vary a lot for one criterion to another, but
the 'tree specific' ones are always the same, except for root'

So, eg :

Root :
CUSTOM INFOS  -  NXT_TYPE  -  NXT_NODEID
azezerert     -  12        -  2
azefsdfsdf    -  15        -  1

For criterion 1 (criterion type =3D 12) :
CUSTOM INFOS  -  NODE_ID  -  NXT_TYPE  -  NXT_ID  -  PREV_TYPE  -  PREV_ID
blabla        -     1     -     ...
sdfsf df      -     2     -     18     -     2    -     1       -     1
sddffsf df    -     2     -     18     -     3    -     1       -     1
blabla        -     3     -     ...

For criterion 2 (criterion type =3D 15) :
CUSTOM INFOS  -  NODE_ID  -  NXT_TYPE  -  NXT_ID  -  PREV_TYPE  -  PREV_ID
sdfsf df      -     1     -     25     -    17    -      1      -     2

...


So I'm trying to get in SQL a simple way to get this structure, in
order to display it on a GUI without having to query the tree as many
times as criterions it contains ...

If someone could help, it would be very appreciated ...

Thanks a lot,=20
--=20
Marc Demlenne
GPG : 768FA483 (http://pgp.mit.edu)
--
//www.freelists.org/webpage/oracle-l

Other related posts: