-
I want to generate a treeview but I have problem with the order of my records.
How can I order a connect by query? I don't want to order all the records set and loose the hierarchy! I want to order each level and keep the hierarchy.
I need help!
Thanks
DONTBSHY
-
It depend from Oracle version:
in old versions (peharps before 9.0.1) u can use:
-- create index on field, that u need sort
-- use HINT with this index
select /*+ index_asc (dc_accs pk_rg_acc) */
RG_ACCOUNT ,
RG_ROOT ,
T_ACCOUNT ,
T_ROOT ,
T_V_ROOT ,
T_V_SIGN ,
CD_EI ,
substr(lpad(' ',(level-1)*4) || NM_ACCOUNT,1,255) ,
substr(lpad(' ',(level-1)*4) || EN_ACCOUNT,1,255) ,
SH_ACCOUNT ,
cd_ldform,
LEVEL
from accs_dictionary
connect by prior rg_account = rg_root
start with rg_root is null;
in 9.0.1 u can use ORDER SIBLINGS BY ..
select RG_ACCOUNT ,
RG_ROOT ,
T_ACCOUNT ,
T_ROOT ,
T_V_ROOT ,
T_V_SIGN ,
CD_EI ,
substr(lpad(' ',(level-1)*4) || NM_ACCOUNT,1,255) ,
substr(lpad(' ',(level-1)*4) || EN_ACCOUNT,1,255) ,
SH_ACCOUNT ,
cd_ldform,
LEVEL
from accs_dictionary
connect by prior rg_account = rg_root
start with rg_root is null
order siblings by sh_account;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|