Take a look at hierarchical queries, in particular the CONNECT BY clause

http://tahiti.oracle.com/pls/db92/db....htm%232076026

HTH