-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE TABLE tt (
    id INTEGER NOT NULL,
    parent INTEGER,
    part VARCHAR(32),
    PRIMARY KEY(id)
);
INSERT INTO tt VALUES(1, NULL, 'movies');
INSERT INTO tt VALUES(2, 1, 'dvd');
INSERT INTO tt VALUES(3, 2, 'horror');
INSERT INTO tt VALUES(4, 2, 'action');

SELECT part FROM tt START WITH id = 3 CONNECT BY PRIOR parent = id;
SELECT part FROM tt START WITH id = 4 CONNECT BY PRIOR parent = id;

DROP TABLE tt;
