Hierarchical sql
hello,
I am seeking help with a hierarchical query.
My table has five columns:
grade (number)
score (number)
name (varchar)
record_id (number)
parentid (number)
A parentid is a record_id at a higher level in the hierarchy.
Grade and Score are used to order (sort) each level of the hierarchy.
The data looks like this:
grade - score - name - record_id - parentid
1 - 1 - name1 - 101 - 0
1 - 2 - name2 - 102 - 0
1 - 3 - name3 - 103 - 0
2 - 1 - name4 - 104 - 101
2 - 2 - name5 - 105 - 101
2 - 1 - name6 - 106 - 102
2 - 2 - name7 - 107 - 102
2 - 1 - name8 - 108 - 103
2 - 2 - name9 - 109 - 103
I would like the query to display the data in the following sequence:
grade - score - name - record_id - parentid
1 - 1 - name1 - 101 - 0
2 - 1 - name4 - 104 - 101
2 - 2 - name5 - 105 - 101
1 - 1 - name2 - 102 - 0
2 - 1 - name6 - 106 - 102
2 - 2 - name7 - 107 - 102
1 - 1 - name3 - 103 - 0
2 - 1 - name8 - 108 - 103
2 - 2 - name9 - 109 - 103
The simplest query to get this resultset sequence is adequate. No need for padding or other features.
Thank you.
All columns in your sample have same order so it isn't possible to tell by what column you want to order siblings. I'll assume by name:
select *
from your_table
start with parentid = 0
connect by parentid = prior record_id
order siblings by name
/For example:
with sample_table as (
select 1 grade,1 score,'name1' name,101 record_id,0 parentid from dual union all
select 1,2,'name2',102,0 from dual union all
select 1,3,'name3',103,0 from dual union all
select 2,1,'name4',104,101 from dual union all
select 2,2,'name5',105,101 from dual union all
select 2,1,'name6',106,102 from dual union all
select 2,2,'name7',107,102 from dual union all
select 2,1,'name8',108,103 from dual union all
select 2,2,'name9',109,103 from dual
select *
from sample_table
start with parentid = 0
connect by parentid = prior record_id
order siblings by name
GRADE SCORE NAME RECORD_ID PARENTID
1 1 name1 101 0
2 1 name4 104 101
2 2 name5 105 101
1 2 name2 102 0
2 1 name6 106 102
2 2 name7 107 102
1 3 name3 103 0
2 1 name8 108 103
2 2 name9 109 103
9 rows selected.
SQL> SY.
Similar Messages
-
CONNECT BY, Performance problems with hierarchical SQL
Hello,
I have a performance problem with the following SQL:
table name: testtable
columns: colA, colB, colC, colD, colE, colF
Following hierarchical SQL:
SELECT colA||colB||colC AS A1, colD||colE||colF AS B1, colA, colB, colC, level
FROM testable
CONNECT BY PRIOR A1 = B1
START WITH A1 = 'aaa||bbbb||cccc'
With big tables the performance of this construct is very bad. I can't use functional based indexes to create an Index on "colA||colB||colC" and "colD||colE||colF"
Has anyone an idea how I can get a real better performance for this hierarchical construct, if I have to combine multiple colums? Or is there any better way (with an PL/SQL or view trigger) solve something like this ??
Thanks in advance for your investigation :)
CarmenWhy not
CONNECT BY PRIOR colA = colD
and PRIOR colB = colE
and ...
? It is not the same thing, but I suspect my version is correct:-) -
Hi
I'm trying to list out all the responsibilities, menus, sub menus, functions attached to a particular user. I need to write a hierarchical query that will recursively pick up the sub menus within other sub menus and list them all out.
Any help would be greatly appreciated!
Thank you,
VVMSorry about that!
Wrote this until I realized I would need some recursive query to get all the sub menus,
SELECT FR.responsibility_key Responsibility , FM.user_menu_name FirstLevelMenu, FM1.user_menu_name SecondLevelMenu, FM2.user_menu_name ThirdLevelMenu
FROM FND_MENUS_TL FM
,fnd_responsibility FR
,FND_USER_RESP_GROUPS_DIRECT FURG
,FND_MENU_ENTRIES FME1
,FND_MENU_ENTRIES FME2
,FND_MENUS_TL FM1
,FND_MENUS_TL FM2
WHERE FR.menu_id = FM.menu_id
AND TRUNC(NVL(FR.end_date,sysdate)) >= TRUNC(sysdate)
AND FR.responsibility_id = FURG.responsibility_id
AND FURG.user_id = '0'
AND TRUNC(NVL(FURG.end_date,sysdate)) >= TRUNC(sysdate)
AND FME1.menu_id = FM.menu_id
AND FME1.sub_menu_id = FM1.menu_id
AND FME2.menu_id = FM.menu_id
AND FME2.sub_menu_id = FM2.menu_id
group BY FR.responsibility_key, FM.user_menu_name, FM1.user_menu_name, FM2.user_menu_name
-VVM -
Hierarchical sql-how to get only branches with at least one not null leaves
On 10gR2 we want below hierarchical query to return only the branches which at least have one not NULL leaf ;
-- drop table corporate_slaves purge ;
create table corporate_slaves (
slave_id integer primary key,
supervisor_id references corporate_slaves,
name varchar(100), some_column number );
insert into corporate_slaves values (1, NULL, 'Big Boss ', NULL);
insert into corporate_slaves values (2, 1, 'VP Marketing', NULL);
insert into corporate_slaves values (9, 2, 'Susan ', NULL);
insert into corporate_slaves values (10, 2, 'Sam ', NULL);
insert into corporate_slaves values (3, 1, 'VP Sales', NULL);
insert into corporate_slaves values (4, 3, 'Joe ', NULL);
insert into corporate_slaves values (5, 4, 'Bill ', 5);
insert into corporate_slaves values (6, 1, 'VP Engineering', NULL);
insert into corporate_slaves values (7, 6, 'Jane ', NULL);
insert into corporate_slaves values (8, 6, 'Bob' , 3);
SELECT sys_connect_by_path(NAME, ' / ') path, some_column col, connect_by_isleaf isLeaf
FROM corporate_slaves
CONNECT BY PRIOR slave_id = supervisor_id
START WITH slave_id IN
(SELECT slave_id FROM corporate_slaves WHERE supervisor_id IS NULL) ;For this example wanted output is like this one since Marketing has no NOT NULL some_column leaves where as Engineering and Sales has at least one;
PATH
/ Big Boss
/ Big Boss / VP Sales
/ Big Boss / VP Sales / Joe
/ Big Boss / VP Sales / Joe / Bill
/ Big Boss / VP Engineering
/ Big Boss / VP Engineering / Jane
/ Big Boss / VP Engineering / Bob Regards.Here is a slightly modified version, you can try it:
WITH SRC AS (
SELECT SYS_CONNECT_BY_PATH(NAME ,
'/ ') path,
SOME_COLUMN COL,
CONNECT_BY_ISLEAF ISLEAF,
CONNECT_BY_ROOT SLAVE_ID ROOT_SLAVE_ID,
SLAVE_ID slave_id,
CONNECT_BY_ROOT SUPERVISOR_ID SUPERVISOR_ID,
SOME_COLUMN
FROM CORPORATE_SLAVES
CONNECT BY PRIOR SLAVE_ID = SUPERVISOR_ID
SELECT path, col, isleaf
FROM SRC
WHERE SUPERVISOR_ID IS NULL
AND SLAVE_ID IN (SELECT ROOT_SLAVE_ID FROM SRC WHERE SOME_COLUMN IS NOT NULL)
PATH COL ISLEAF
/ Big Boss 0
/ Big Boss / VP Sales 0
/ Big Boss / VP Sales/ Joe 0
/ Big Boss / VP Sales/ Joe / Bill 5 1
/ Big Boss / VP Engineering 0
/ Big Boss / VP Engineering/ Bob 3 1
6 rows selectedI tested it for 1000 records in the source table (tested on Oracle 10 XE),
and .... the performance was a big surprise:
INSERT INTO corporate_slaves
SELECT SLAVE_ID + X SLAVE_ID,
SUPERVISOR_ID + X SUPERVISOR_ID,
NAME || ' ' || X NAME,
some_column
FROM CORPORATE_SLAVES
CROSS JOIN (
SELECT 10*LEVEL x
FROM DUAL
CONNECT BY LEVEL <= 100
COMMIT;
SELECT count(*) FROM corporate_slaves;
COUNT(*)
1010 Your query (slightly modified - removed leading space from the separator in CONNECT_BY_PATH):
set timings on;
CREATE TABLE BUBA1 AS
SELECT SYS_CONNECT_BY_PATH(NAME,
'/ ') path,
some_column col,
connect_by_isleaf isleaf
FROM corporate_slaves
WHERE slave_id IN (SELECT connect_by_root slave_id "slave_id"
FROM corporate_slaves
WHERE some_column IS NOT NULL
CONNECT BY PRIOR slave_id = supervisor_id)
CONNECT BY PRIOR slave_id = supervisor_id
START WITH SLAVE_ID IN
(SELECT SLAVE_ID FROM CORPORATE_SLAVES WHERE SUPERVISOR_ID IS NULL)
CREATE TABLE succeeded.
6 095ms elapsedrewritten query:
CREATE TABLE BUBA2 AS
WITH SRC AS (
SELECT SYS_CONNECT_BY_PATH(NAME ,
'/ ') path,
SOME_COLUMN COL,
CONNECT_BY_ISLEAF ISLEAF,
CONNECT_BY_ROOT SLAVE_ID ROOT_SLAVE_ID,
SLAVE_ID slave_id,
CONNECT_BY_ROOT SUPERVISOR_ID SUPERVISOR_ID,
SOME_COLUMN
FROM CORPORATE_SLAVES
CONNECT BY PRIOR SLAVE_ID = SUPERVISOR_ID
SELECT path, col, isleaf
FROM SRC
WHERE SUPERVISOR_ID IS NULL
AND SLAVE_ID IN (SELECT ROOT_SLAVE_ID FROM SRC WHERE SOME_COLUMN IS NOT NULL)
CREATE TABLE succeeded.
167ms elapsed
SELECT COUNT(*) FROM BUBA1;
COUNT(*)
606
SELECT COUNT(*) FROM BUBA2;
COUNT(*)
606
SELECT COUNT(*) FROM(
SELECT * FROM BUBA1
INTERSECT
SELECT * FROM BUBA2
COUNT(*)
606 ANd now the above tests repeated for 10.000 records
truncate table corporate_slaves;
insert into corporate_slaves values (1, NULL, 'Big Boss ', NULL);
insert into corporate_slaves values (2, 1, 'VP Marketing', NULL);
insert into corporate_slaves values (9, 2, 'Susan ', NULL);
insert into corporate_slaves values (10, 2, 'Sam ', NULL);
insert into corporate_slaves values (3, 1, 'VP Sales', NULL);
insert into corporate_slaves values (4, 3, 'Joe ', NULL);
insert into corporate_slaves values (5, 4, 'Bill ', 5);
insert into corporate_slaves values (6, 1, 'VP Engineering', NULL);
insert into corporate_slaves values (7, 6, 'Jane ', NULL);
insert into corporate_slaves values (8, 6, 'Bob' , 3);
INSERT INTO corporate_slaves
SELECT SLAVE_ID + X SLAVE_ID,
SUPERVISOR_ID + X SUPERVISOR_ID,
NAME || ' ' || X NAME,
some_column
FROM CORPORATE_SLAVES
CROSS JOIN (
SELECT 10*LEVEL x
FROM DUAL
CONNECT BY LEVEL <= 1000
COMMIT;
SELECT count(*) FROM corporate_slaves;
COUNT(*)
10010
CREATE TABLE BUBA22 AS
WITH SRC AS (
SELECT SYS_CONNECT_BY_PATH(NAME ,
'/ ') path,
SOME_COLUMN COL,
CONNECT_BY_ISLEAF ISLEAF,
CONNECT_BY_ROOT SLAVE_ID ROOT_SLAVE_ID,
SLAVE_ID slave_id,
CONNECT_BY_ROOT SUPERVISOR_ID SUPERVISOR_ID,
SOME_COLUMN
FROM CORPORATE_SLAVES
CONNECT BY PRIOR SLAVE_ID = SUPERVISOR_ID
SELECT path, col, isleaf
FROM SRC
WHERE SUPERVISOR_ID IS NULL
AND SLAVE_ID IN (SELECT ROOT_SLAVE_ID FROM SRC WHERE SOME_COLUMN IS NOT NULL)
CREATE TABLE succeeded.
345ms elapsed
CREATE TABLE BUBA11 AS
SELECT SYS_CONNECT_BY_PATH(NAME,
'/ ') path,
some_column col,
connect_by_isleaf isleaf
FROM corporate_slaves
WHERE slave_id IN (SELECT connect_by_root slave_id "slave_id"
FROM corporate_slaves
WHERE some_column IS NOT NULL
CONNECT BY PRIOR slave_id = supervisor_id)
CONNECT BY PRIOR slave_id = supervisor_id
START WITH SLAVE_ID IN
(SELECT SLAVE_ID FROM CORPORATE_SLAVES WHERE SUPERVISOR_ID IS NULL)
CREATE TABLE succeeded.
526 437ms elapsed
SELECT COUNT(*) FROM BUBA11;
COUNT(*)
6006
SELECT COUNT(*) FROM BUBA22;
COUNT(*)
6006
SELECT COUNT(*) FROM(
SELECT * FROM BUBA11
INTERSECT
SELECT * FROM BUBA22
COUNT(*)
6006 Wow.... 526 seconds vs. 0,4 seconds !!!
131500 % performance gain ;)
I have got similar results on Oracle 11.2 -
Hi
SQL : 1
Following Hierarchical SQL giving output with 2 seconds with 1169 records.
SELECT LPAD ('.', 2 * (LEVEL - 1), '.') || LEVEL bom_level,
msia.segment1
|| '.'
|| msia.segment2
|| '.'
|| msia.segment3
|| '.'
|| msia.segment4 parent_item_code,
msia.description parent_description, msia.primary_unit_of_measure,
LPAD ('.', 2 * (LEVEL - 1), '.')
|| msic.segment1
|| '.'
|| msic.segment2
|| '.'
|| msic.segment3
|| '.'
|| msic.segment4 component_item_code,
msic.description component_description, bic.operation_seq_num,
bic.component_quantity
FROM bom_bill_of_materials bom,
bom_inventory_components bic,
mtl_system_items msia,
mtl_system_items msic
WHERE bic.bill_sequence_id = bom.bill_sequence_id
AND msia.inventory_item_id = bom.assembly_item_id
AND msia.organization_id = bom.organization_id
AND msic.inventory_item_id = bic.component_item_id
AND msic.organization_id = bom.organization_id
START WITH bom.assembly_item_id = 1407543
AND bom.organization_id = 56
CONNECT BY bom.assembly_item_id = PRIOR bic.component_item_id
AND bom.organization_id = 56;
SQL : 2
Following SQL giving output = 1407543
SELECT e.equipment_item_id FROM websupp.epa_transaction_header e WHERE equipment_id = 34
Now, when I am replacing START WITH clause of SQL:1 with SQL:2 means to replace 1407543 with SQL:2, it is taking so long time .
Can you guide me in tuning SQL :1
Thanks in advance
Sanjaytry something
with t as
SELECT e.equipment_item_id val FROM websupp.epa_transaction_header e WHERE equipment_id = 34
SELECT LPAD ('.', 2 * (LEVEL - 1), '.') || LEVEL bom_level,
msia.segment1
|| '.'
|| msia.segment2
|| '.'
|| msia.segment3
|| '.'
|| msia.segment4 parent_item_code,
msia.description parent_description, msia.primary_unit_of_measure,
LPAD ('.', 2 * (LEVEL - 1), '.')
|| msic.segment1
|| '.'
|| msic.segment2
|| '.'
|| msic.segment3
|| '.'
|| msic.segment4 component_item_code,
msic.description component_description, bic.operation_seq_num,
bic.component_quantity
FROM bom_bill_of_materials bom,
bom_inventory_components bic,
mtl_system_items msia,
mtl_system_items msic,
t t
WHERE bic.bill_sequence_id = bom.bill_sequence_id
AND msia.inventory_item_id = bom.assembly_item_id
AND msia.organization_id = bom.organization_id
AND msic.inventory_item_id = bic.component_item_id
AND msic.organization_id = bom.organization_id
START WITH bom.assembly_item_id = t.val --1407543
AND bom.organization_id = 56
CONNECT BY bom.assembly_item_id = PRIOR bic.component_item_id
AND bom.organization_id = 56; -
Cursor For Loop SQL/PL right application? Need help with PL Performance
I will preface this post by saying that I am a novice Oracle PL user, so an overexplanation would not be an issue here.
Goal: Run a hierarchial query for over 120k rows and insert output into Table 1. Currently I am using a Cursor For Loop that takes the first record and puts 2 columns in "Start" section and "connect by" section. The hierarchial query runs and then it inserts the output into another table. I do this 120k times( I know it's not very efficient). Now the hierarchial query doesn't take too long ( run by itself for many parts) but this loop process is taking over 9 hrs to run all 120k records. I am looking for a way to make this run faster. I've read about "Bulk collect" and "forall", but I am not understanding how they function to help me in my specific case.
Is there anyway I can rewrite the PL/SQL Statement below with the Cursor For loop or with another methodology to accomplish the goal significantly quicker?
Below is the code ( I am leaving some parts out for space)
CREATE OR REPLACE PROCEDURE INV_BOM is
CURSOR DISPATCH_CSR IS
select materialid,plantid
from INV_SAP_BOM_MAKE_UNIQUE;
Begin
For Row_value in Dispatch_CSR Loop
begin
insert into Table 1
select column1
,column2
,column3
,column4
from( select ..
from table 3
start with materialid = row_value.materialid
and plantid = row_value.plantid
connect by prior plantid = row.value_plantid
exception...
end loop
exception..
commitBluShadow:
The table that the cursor is pulling from ( INV_SAP_BOM_MAKE_UNIQUE) has only 2 columns
Materialid and Plantid
Example
Materialid Plantid
100-C 1000
100-B 1010
X-2 2004
I use the cursor to go down the list 1 by 1 and run a hierarchical query for each row. The only reason I do this is because I have 120,000 materialid,plantid combinations that I need to run and SQL has a limit of 1000 items in the "start with" if I'm semi-correct on that.
Structure of Table it would be inserted into ( Table 1) after Hierarchical SQL Statement runs:
Materialid Plantid User Create Column1 Col2
100-C 1000 25 EA
The Hierarchical query ran gives the 2 columns at the end.
I am looking for a way to either just run a quicker SQL or a more efficient way of running all 120,000 materialid, plantid rows through the Hierarchial Query.
Any Advice? I really appreciate it. Thank You. -
Hi all,
I need to find out all the nested procedure or functions list which are invoked by a particular procedure or function.I am trying to write code which I am using recursion.I am facing problem in storing values in INTO clause of the SELECT statement because multiple procs can not be stored on one index i.e proclist_v(i).Should I use any other type of object other than pl/sql table.please give me an idea
CREATE OR REPLACE PACKAGE finddblink_pack
IS
TYPE NameType IS TABLE OF
dba_dependencies.referenced_name%TYPE
INDEX BY BINARY_INTEGER;
PROCEDURE finddblink_proc (proc_par NameType)
END finddblink_pack;
CREATE OR REPLACE PACKAGE BODY finddblink_pack
IS
PROCEDURE finddblink_proc (proc_par NameType)
IS
proclist_v NameType;
BEGIN
FOR i in func_par.FIRST .. func_par.LAST LOOP
SELECT referenced_name
INTO proclist_v(i)
FROM dba_dependencies
WHERE name=upper(func_par(i))
AND referenced_type in('FUNCTION','PROCEDURE','PACKAGE BODY');
finddblink(proclist_v);
END LOOP;
END finddblink_proc;
END finddblink_pack;Well, you do not need recursive plsql for that. Hierarchical SQL will do:
SQL> CREATE OR REPLACE
2 PROCEDURE P1
3 IS
4 BEGIN
5 NULL;
6 END;
7 /
Procedure created.
SQL> CREATE OR REPLACE
2 PROCEDURE P2
3 IS
4 BEGIN
5 P1;
6 END;
7 /
Procedure created.
SQL> CREATE OR REPLACE
2 PROCEDURE P3
3 IS
4 BEGIN
5 P2;
6 END;
7 /
Procedure created.
SQL> SELECT referenced_name
2 FROM dba_dependencies
3 START WITH name = 'P3'
4 CONNECT BY prior referenced_name = name
5 AND referenced_type in('FUNCTION','PROCEDURE','PACKAGE BODY')
6 /
REFERENCED_NAME
P2
P1
SQL> SY. -
Using a WHERE clause in APEX Tree
Hi All -
I have an hierarchical SQL query that I'm displaying as an APEX tree.
My sample app is here:
https://apex.oracle.com/pls/apex/f?p=32581:29
login: guest
pw: app_1000
workspace: leppard
I am trying to add a WHERE clause so that only nodes with the lowest level children are displayed, i.e. something like 'WHERE connect_by_isleaf = 0 OR level = 5'
The tree query with the where clause works fine in the SQL commands window, but when I add the WHERE clause to my apex tree the page no longer displays anything. Is this an issue with APEX or is there some other way to filter my results?
Thanks in advance for any suggestions,
johnConnect by occurs first, the where clause then is applied to those results, effectively cutting away in the hierarchical structure. Since apex has to build a hierarchical structure from the query it relies on the level pseudocolumn, which is butchered by applying the where clause. It's a miracle you aren't even receiving errors because I'd almost expect an incorrect json array to have been built. With no top level to start from and only level 5 or leaf nodes there is no structure to present: both apex can not put out a correct representation and not jstree either. In your query you will see your "root nodes" but it is not representable.
I'm not sure why you want to present this in a tree? Both connect_by_is_leaf and level = 5 will simply give you a list of nodes without any hierarchical structure.
The better thing to do is to use a subquery to first limit your dataset and then use that to base the tree query on, that way you don't break any of those vital columns.
Eg if you only want leaf nodes and their immediate parent you could go for something like this (quick mockup on some testdata):
with dataset as (
select node_id, parent_id
from treedata
where connect_by_isleaf = 0
connect by prior node_id = parent_id
start with parent_id = 0
dataset2 as (
select node_id, parent_id
from dataset
union all
select node_id, null parent_id
from treedata
where node_id in (select parent_id from dataset)
select level, node_id
from dataset2
connect by prior node_id = parent_id
start with parent_id is null -
How to check the selected items of a selectManyListbox in doDML of an EO ?
Hello,
I have a VO based on en EO. During the doDML(UPDATE) of that EO, I would like to check what items of a af:selectManyListbox have been selected.
How could I get the checked items in the selectManyListbox (which belongs to the ViewController) in the doDML method of an EO (which belongs to the Model)?
Many thanksHello John,
I know I cannot access the component directly. This is why I asked my question.
The real case is rather complex and long to be copied and pasted here.
Let me simplify it without being too generic.
The VO is based on a hierarchical SQL query. All its EO attributes are transient. This VO is shown as a Tree in the page.
Each node of the Tree has a checkBox. During commit (doDML() of the EO to be precise), for each checked node I need to access the selected items of a selectManyListbox in some proper way to perform further operations on the DB (no matter what now). The selectManyListbox is based on a second VO. As you may understand, the problem is that from the EO I don't have a direct access to the selectManyListbox. Also, as far as I know, the VO the selectManuListBox is based on does not have any informations about the selected elements, since the checkBox in the list cannot be associated to the VO. Basically I cannot know what elements have been choosen.
I hope the problem is clear. -
Hierarchial Structure with Child Parameter
I have a query like this
select child
from t
START WITH parent = 'DIV'
CONNECT BY PRIOR child= parent
when i give some parent value its fetching the entire structure from DIV parent.
i need to restric the rows to some specific leaf. i.e i need a additional parameter called child where i will child value so that it have return only the row from that parent to given child.I dont need other trees.
For eg DIV is parent for A, B ,C
A is parent for D,E
B is parent of F,G,H
C has no child.
If i give parameter DIV is parent and G has child i need only this hierarchy. this should return only two rows
A and G
Please let me know if i am not clear..
Pls Help
VInoth.Maybe combining the two hierarchies:
SQL> with t as (
2 select 'A' child, 'DIV' parent from dual union all
3 select 'B' child, 'DIV' parent from dual union all
4 select 'C' child, 'DIV' parent from dual union all
5 select 'D' child, 'A' parent from dual union all
6 select 'E' child, 'A' parent from dual union all
7 select 'F' child, 'B' parent from dual union all
8 select 'G' child, 'B' parent from dual union all
9 select 'H' child, 'B' parent from dual
10 )
11 select t1.child, t2.lev
12 from (select child from t CONNECT BY prior parent=child start with child='G') t1,
13 (select child, level lev from t CONNECT BY prior child=parent start with parent='DIV') t2
14 where t1.child=t2.child;
CHILD LEV
B 1
G 2you can add a condition on LEV that is the level in the top-down hierarchy...
But I think this could be slow...
Max -
Hi,
i want to write a function or a pipelined function which will process data from a given table. the structure of the table is as below :
clasec_menu_m
MENU_LEVEL
IS_MENU_A_LEAF
MENU_ID
MENU_NAME
MENU_TITLE
MENU_DESCRIPTION
MENU_PARENT_ID
MENU_SCREEN_URI
SCREEN_TARGET_FRAME
MENU_ICON_URL
now i need to convert it only a xml using these steps
1. if menu_level=1 then
a root node called menu has to be created and another node under it has to be created this will be called subemenu.
2. a) If menu_level =1 and is_menu_a_leaf =1 then add item node to the above menu or submenu node with MENU_SCREEN_URI.
b). If menu_level =1 and is_menu_a_leaf <>1 then add item node to the above menu and a subitem node to the menu node.
this process has to be repeated untill menu_level=1 im that case go to step2 again.
This is very urgent. U can mail me at [email protected]
Regards,
Vikas KumarYou have asked this question about XML menu generation in 3 postings thus far in this forum, if I'm not mistaken.
I still struggle to understand what your actual problem is. And perhaps the reason for that is you have not accurately identify The Problem - and that is mandatory when you want to solve it.
Whenever dealing with any problem, you need to break it down into simpler problems.
How to write hierarchical queries? This is one of the problems as a typical menu structure is hierarchical. And when dealing with a hierarchical SQL problem, first make it simpler. Use a basic and simple data set that you understand - limited number of rows and columns. Understand how it works and then apply this to the real data set.
Need to generate XML? This is another Problem Block to solve. On its own first. There are numerous source examples on this forum about how to generate XML (including some of mine). A simple search should turn these up. Referring to the Oracle manuals is always an excellent idea (http://tahiti.oracle.com).
Problems with any of these two Problem Blocks, ask specific technical questions in this forum:
- showing the Oracle version you're using
- describing the basic problem
- listing your attempts (you providing the basic code and test data make it a lot easier for forum members to assist you)
The next Problem Block is to combine the solutions of the previous two problems into a single all-encompassing solution.
Is a pipeline table function the answer? That depends on numerous factors such as the type of client making the call, the format the data is expected in, etc.
Do you return it as a CLOB? As an Oracle XML DOM type? As series of varchar2 lines? Do you return it using a PL/SQL interface? Do you return it using a SQL interface? How do you address issues like the client passing parameters, security, etc?
It seems to me that you are jumping from one problem issue to another, not really solving anyone specifically and then making the assumption that a pipeline table is The Answer.
The Answer can only be found when The Question is unambiguous and clear. And in order to have a meaningful answer, the question need to be specific. In other words, deal with actual basic problems separately instead of describing the global problem here (that simply raises more questions) and then asking for an answer. -
CONNECT BY query performance resources for 10.2
I couldn't find any relevant resource, I am planning to use hierarchical sql option on a mass of data so any kind of advice, hint or resource to read especially related to indexing, partitining benefits to CONNECT BY query will be appreciated
Thank you.The best place is to look in the documentation... (http://www.oracle.com/pls/db102/search?remark=quick_search&word=connect+by&tab_id=&format=ranked)
Performance is not just black and white, but will depend on many factors, so without knowing your data or what you are trying to achieve and without you having tried to produce some queries and provide explain plans and traces, we're not going to be able to give any specific advice. -
I would like to create a region that combines the following tree and report region features.
TREE FUNCTIONALITY:
- the ability to show/hide individual nodes.
REPORT FUNCTIONALITY:
- the ability to display multiple fields
- highlight search words
- have multiple drill down paths in one row.
I've played a little with the following two ideas:
1. Base the report on a collection that has a hide/show flag. Create a report link that runs a process that updates this field. My concern with this approach is performance. I found the report based on a collection takes more time than running directly against the database. In production this issue will be greater as every user will be caching a fairly large collection every time they log onto to the system.
2. Use the connect_by function to create a hierarchical sql result set and then use javascript to show/hide nodes. However, I could figure out how to hide nodes/rows using javascript.
Does anyone have any suggestions?
Thanks,
DavidOn Thu, 14 Apr 2011 10:06:04 +0000, cps7 wrote:
> ZLM73 creates a eDir tree on install. Is that tree used only for ZLM and
> I need another tree to keep all user information? Or should I create
> another tree to keep users profiles?
>
> Also is this a good approach if I want in future expand network with win
> server and win xp machine and ZDM?
That tree is meant just for ZLM itself. That one uses it as the object
store where meta data of the all the bundles, devices, policies and so on
is stored. I should not be used for other things.
You know that ZCM 11 is out for a few months now and that is the next
version of ZLM. Not everything is in for the linux systems, but for the
windows systems. So if you plan to have both worlds, I would take a look
at that and see if it fits your needs better then ZLM which you can use
only for linux systems.
Rainer -
....Tree structure problem
Hi all
i am able to populate a tree structure.
The Root Nodes displays the Name of the Employees and each roots childs display 2nd level root named, New Request recieved, Cancelled requests.
Now i want is that whenever the application runs, only the employee should expand its own Node. and if it clicks the node of other employeess , their Node should not Expand. ...
I dont know how to do that ..
i know there is a trigger when node expand, but i dont know how to use the check...
I mean suppose
x:=Get_application_property(USERNAME);
if :NODE_Label <> x then
msg ('''dont open in others mail box');
Raise Form trigger Failure
end if
Is this code ok..
kindly reply ..
thnx alotI assume you're creating the tree with a 'connect by' query, so why not just use the query to filter out the nodes you don't want to be viewed?
Eg, table ee with this data (I use ¬ as my null indidcator):
SQL> SELECT * FROM ee;
A B
¬ BOB
¬ JACK
¬ TOM
BOB New
JACK New
TOM New
BOB Cancelled
JACK Cancelled
TOM Cancelled
9 rows selected.Selecting all rows hierarchically:
SQL> SELECT LPad(' ',(level - 1) * 4,' ')||b
2 FROM ee
3 CONNECT BY PRIOR b = a
4 START WITH a IS NULL;
LPAD('',(LEVEL-1)*4,'')||B
BOB
New
Cancelled
JACK
New
Cancelled
TOM
New
Cancelled
9 rows selected.Selecting child nodes for BOB and no other:
SQL> SELECT LPad(' ',(level - 1) * 4,' ')||b
2 FROM ee
3 WHERE a = 'BOB' OR a IS NULL
4 CONNECT BY PRIOR b = a
5 START WITH a IS NULL;
LPAD('',(LEVEL-1)*4,'')||B
BOB
New
Cancelled
JACK
TOM
SQL> -
PL/SQL Hierarchical Profiler: plshprof output - meaning of Ind% column
Hi,
During analysis of an PL/SQL Performance issue I started using the DBMS_HPROF Profiler, but could not find a good source of information about interpreting the out html-files.
I went through the Database advanced Application Developers Guide chapter: "Using the PL/SQL Hierarchical Profiler" which has a small section explaining the html output generated by this tool.
I'm aware of the possibility of using the analyze function for populating the DBMSHP_* Tables, but I would like also to use the html output too.
Unfortunately there is no explanation about the Ind% column in the various html pages in the documentation. Searching the internet didn't bring up much information either.
for example:
Function Elapsed Time (microsecs) Data sorted by Total Subtree Elapsed Time (microsecs)
18824664856 microsecs (elapsed time) & 23390789 function calls
Subtree Ind% Function Ind% Descendants Ind% Calls Ind% Function Name
18598289260 98.8% 42540820 0.2% 18555748440 98.6% 697210 3.0% __static_sql_exec_line34 (Line 34)
18555748440 98.6% 1660109 0.0% 18554088331 98.6% 697210 3.0% __plsql_vm
.Has someone used this tool and knows the meaning ?
best regardsCan you give me a hint how "C u m %" Column is calculated
Function Elapsed Time (microsecs) Data sorted by Total Function Elapsed Time (microsecs)
20052584182 microsecs (elapsed time) & 26511278 function calls
Subtree Ind% Function Ind% C u m % Descendants Ind% Calls Ind% Function Name
8920721699 44.5% 8745800186 43.6% 43.6% 174921513 0.9% 15990 0.1% WM.LOG_INSTEAD_TRG.__dyn_sql_exec_line127 (Line 127)
10133224678 50.5% 7440629835 37.1% 80.7% 2692594843 13.4% 790323 3.0% WM.LOG_INSTEAD_TRG.__dyn_sql_exec_line96 (Line 96)
607218527 3.0% 607218527 3.0% 83.7% 0 0.0% 60200 0.2% OWNER.LOG_UMTAEUSCHE_U.__static_sql_exec_line763 (Line 763)Sorry but had to write c u m % because otherwise it gets starred out
Maybe you are looking for
-
I can only print the current page of downloaded pdf's. Not able to print "all". I'm using a Macbook air.
-
How to get cumulative in reports
Hi There.. I am supposed to get the following format. The Data which I retrieved frm the query is 'a' and 'Total'.For 'Cumulative Total' I have to get it frm 'a' and 'total'..... I hope u guys got the point... a Total Cumulative Total a100 100 0 150
-
Regarding Connecting Multiple BI Systems to single R3 System
Hi, We have perform R3load based system copy of our BW Systems dev/qa/prod. Now, we have D4D/D4T/D4P as one new BW Landscape we have D2D/D2T/D2P as original BW Landscape We have R8D/R8T/R1P as R3 Landscape. Original BW Landscape is already connect to
-
How to solve strange Console messages
Hi, as the backup takes ages I opened the Console and found (among others) the following messages: 6/10/10 7:31:14 PM com.apple.backupd[885] 2010-06-10 19:31:14.561 diskimages-helper[889:1603] Error loading /Library/Plug-ins/DiskImages/NUMPlugin.bund
-
Wireless QoS - CAPWAP getting tagged DSCP 26 while inner packet is DSCP 24.
Hello, I'm facing an issue regarding QoS and wireless. I've attached a drawing of my set up as well. My set up consists of a Cisco wireless 7925 phone, a 3702i access point, and a WISM2 controller (running newest 7.6 code). My access point is conne