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

Home -> Community -> Usenet -> c.d.o.tools -> Copying tree-like data

Copying tree-like data

From: Stefan Larsson <d95stela+news_at_dtek.chalmers.se>
Date: 27 Nov 2000 17:22:58 GMT
Message-ID: <slrn92563i.f5r.d95stela+news@licia.dtek.chalmers.se>

Hi!

What is the best way of copying tree-like data?

I have a table looking like:

CREATE TABLE t1 (

  ID_        INTEGER,
  Data       ...,

  Parent_ID_ INTEGER
);

where parent_id_ identifies other rows in t1.

I also have the sequence seq_IDs to generate unique IDs.

I'm trying to create a PL/SQL procedure 'Copy' which will start at a specified ID and make a copy of the tree from the specified row and down, using fresh IDs from the sequence and connecting them in the proper way.

The obvious solution (to me, anyway) is to use a recursive procedure, but I have a feeling that there should be a more efficient way, maybe using Oracle's START WITH/CONNECT BY queries.

Any suggestions?

/stefan Received on Mon Nov 27 2000 - 11:22:58 CST

Original text of this message

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