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

Home -> Community -> Usenet -> c.d.o.server -> Re: Organize data for a TreeView

Re: Organize data for a TreeView

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Tue, 21 Sep 1999 12:29:10 +0200
Message-ID: <7s7mn3$2t3$1@oceanite.cybercable.fr>


You can use the connect by with your table:

v734>create table t (law_id number, lawarea varchar2(100), parent_id number);

Table created.

v734>insert into t values (1,'LawArea_1',NULL);

1 row created.

v734>insert into t values (2,'LawArea_2',NULL);

1 row created.

v734>insert into t values (3,'LawArea_3',NULL);

1 row created.

v734>insert into t values (4,'LawArea_1_a',1);

1 row created.

v734>insert into t values (5,'LawArea_1_b',1);

1 row created.

v734>insert into t values (6,'LawArea_1_b_1',5);

1 row created.

v734>select * from t connect by parent_id=prior law_id start with parent_id is null;

    LAW_ID LAWAREA PARENT_ID

---------- -------------------- ----------
         1 LawArea_1
         4 LawArea_1_a                   1
         5 LawArea_1_b                   1
         6 LawArea_1_b_1                 5
         2 LawArea_2
         3 LawArea_3

6 rows selected.

v734>select lpad(' ',2*(level-1))||lawarea from t  connect by parent_id=prior law_id start with parent_id is null;

LPAD('',2*(LEVEL-1))||LAWAREA



LawArea_1
  LawArea_1_a
  LawArea_1_b
    LawArea_1_b_1

LawArea_2
LawArea_3

6 rows selected.

Magnus S. Petersen a écrit dans le message <37e4b4b4_at_news.olivant.fo>...
>Working with Delphi 5 Enterprise and Oracle 8,Personal Edition.
>I want to use a TreeView in a form to display data hierarchally to the user.
>|--lawarea_1
>| |--LawArea_1_a
>| |--LawArea_1_b
>| |--LawArea_1_b_1
>| |--LawArea_1_b_2
>| |--LawArea_1_b_3
>| |--LawArea_1_b_3_a
>| |--LawArea_1_b_3_b
>| |--LawArea_1_b_3_c
>| |--LawArea_1_b_3_d
>| |--LawArea_1_b_3_d_1
>| |--LawArea_1_b_3_d_2
>|--LawArea_2
>| |--LawArea_
>| |--LawArea_
>| |_LawArea_
>| |_LawArea_
>etcetera
>
>What would be the best way to organize the data in the database table. I
>have orgarnized the data in 3 columns as follows:
>Law_id LawArea Parent_id
>1 LawArea_1 NULL
>2 LawArea_2 NULL
>3 LawArea_3 NULL
>4 LawArea_1_a LawArea_1
>5 LawArea_1_b LawArea_1
>6 LawArea_1_b_1 LawArea_1_b
>etc.
>Parent_id is a foreign key referencing to the primary key Law_id of the same
>table.
>I retreive a result set through a procedure residing in a package in the
>database and iterate through the result set
>with a While not EOF do loop.
>This takes some time as the result set is very big. Compared to the very
>simple methods of the TreeView LoadFromFile and SaveToFile, my approach
>looks clumsy.
>Is there an elegant way to do this ? and would some mercy soul give me an
>example
>Regards
>Magnus
>
>
>
Received on Tue Sep 21 1999 - 05:29:10 CDT

Original text of this message

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