Need to populate a hierarchical query results in detail block of WIPTXCFM
Hi All,
I would need to customize WIPTXCFM to populate all layered sub assembly schedule numbers against a Final Assembly schedule number.
Requirement is as soon as User enter a FA schedule number; it should populate all levels Sub Assembly Schedule Numbers under this.
I have thought of 1 approach; need suggestion if there is any better way to achieve this to improve the performance.
My Approach: In custom WIPTXCFM form once the FA schedule number is entered; I can fetch all below level data(e.g Level1, level2 ...etc.)
using a cursor with hierarchical query. Then loop through the cursor and insert them in the block after the FA record.
So would look for your suggestion if there is any other better way to achieve this.
Thanks in adv.
Regards.
880860 wrote:
Hi All,
I would need to customize WIPTXCFM to populate all layered sub assembly schedule numbers against a Final Assembly schedule number.
Requirement is as soon as User enter a FA schedule number; it should populate all levels Sub Assembly Schedule Numbers under this.
I have thought of 1 approach; need suggestion if there is any better way to achieve this to improve the performance.
My Approach: In custom WIPTXCFM form once the FA schedule no is entered; I can fetch all below level data(e.g Level1, level2 ...etc.)
using a cursor with hierarchical query. Then loop through the cursor and insert them in the block after the FA record.
As per my findings; this hierarchical query takes longer to fetch the below levels data, around 1.5 mins.
Hello 880860,
If your are talking about EBS customization you can post at {forum:id=475}.
Hope this helps
Similar Messages
-
Requirement with hierarchical query results
I've a table contains the following columns and the data
create table test_test2 (do_id_tp varchar2(32),do_id number ,do_up_tp varchar2(32),do_up_id number)
insert into test_test2 values('A_S',100170,'A_S',100001);
insert into test_test2 values('P_G',1001052,'P_G',100001);
insert into test_test2 values('A_S',1001054,'P_G',100001);
insert into test_test2 values('A_S',1001055,'P_G',100001);
insert into test_test2 values('P_G',1001037,'P_G',100001);
insert into test_test2 values('P_G',1001038,'P_G',100001);
insert into test_test2 values('A_S',1001053,'P_G',100001);
insert into test_test2 values('A_S',1001056,'P_G',100001);
insert into test_test2 values('A_S',1001052,'P_G',100001);
insert into test_test2 values('A_S',1001051,'P_G',100001);
insert into test_test2 values('P_G',100001,'R_S',100001);
insert into test_test2 values('P_G',1001031,'R_S',100001);
insert into test_test2 values('P_G',1001035,'R_S',100001);
insert into test_test2 values('A_S',100170,'P_G',100001);
insert into test_test2 values('A_S',1001054,'A_S',100001);
insert into test_test2 values('A_S',1001055,'A_S',100001);
insert into test_test2 values('A_S',1001053,'A_S',100001);
insert into test_test2 values('A_S',1001056,'A_S',100001);
insert into test_test2 values('A_S',1001051,'A_S',100001);
insert into test_test2 values('A_S',1001052,'A_S',100001);
insert into test_test2 values('A_S',100001,'P_G',100001);In the above data R_S is at high level (Means P_G and A_S should depend on R_S)
similarly P_G is next level ( A_S should depend on P_G OR P_G depends on P_G)
the lower level is A_S ( A_S depends on A_S)
So i tried the following query which gives the child list of a parent
SELECT DO_UP_TP,DO_UP_ID ,do_id_tp,wm_concat( CONNECT_BY_ROOT do_id)
FROM test_test2
where do_up_id=100001
CONNECT BY nocycle PRIOR do_up_id = do_id
group by DO_UP_TP,DO_UP_ID ,do_id_tp;The requirement is for each do_up_id ( i'll get a list of do_id (which are in wm_concat).).
i've to check in flag column in Following table
create table check_test2 (d_id ) as
select do_up_id from test_test2 union
select do_id from test_test2
alter table check_test2 add (flag char(1) DEFAULT 'N')For Ex: R_S (100001) has the childs P_G(100001),P_G(1001031),P_G(1001035) {This is a branch in a Tree}
Now first i've to check R_S(100001) is active or not in the check_test2 table, If 'N' then check it's child's flag until it finds no more childs.
If no child is having 'Y' then mark the entire branch as 'N'
This i've to do for all the do_up_id in TEST_TEST2 table.
I tried the following package plz correct me as per requirement
CREATE OR REPLACE package USPF_APR.test_pak1 as
FUNCTION map_object ( obj_typ_in VARCHAR2 ) RETURN VARCHAR2;
CURSOR c_c1
IS
select * from test_test2 where (do_id in (100001) or do_up_id in (100001));
TYPE test_ttyp IS TABLE OF c_c1%ROWTYPE INDEX BY PLS_INTEGER;
procedure search_obj(obj_type varchar2);
end;
CREATE OR REPLACE package body USPF_APR.test_pak1 as
FUNCTION map_object ( obj_typ_in VARCHAR2 ) RETURN VARCHAR2
IS
begin
dbms_output.put_line ('Hello');
return 'abc';
end;
PROCEDURE search_obj (obj_type VARCHAR2)
IS
test_tab test_ttyp;
test_tab_r c_c1%ROWTYPE;
dep_up_id NUMBER;
dep_id NUMBER;
con_dep_up_id VARCHAR2(2100);
con_dep_id VARCHAR2(2100);
BEGIN
OPEN c_c1;
LOOP
Fetch c_c1 into test_tab_r;
exit when c_c1%NOTFOUND;
test_tab(test_tab.COUNT + 1) := test_tab_r;
END LOOP;
CLOSE c_c1;
DBMS_OUTPUT.put_line ('Test_tab.count is ...'|| test_tab.COUNT);
FOR i IN 1 .. test_tab.COUNT LOOP
WITH T AS
( SELECT test_tab(i).do_id , test_tab(i).do_up_id
FROM DUAL)
SELECT test_tab(i).do_up_id ,wm_concat( CONNECT_BY_ROOT test_tab(i).do_id) INTO dep_up_id ,dep_id
FROM T
CONNECT BY nocycle PRIOR test_tab(i).do_up_id=test_tab(i).do_id
group by test_tab(i).do_up_id;
con_dep_id := con_dep_id || ',' || dep_id;
DBMS_OUTPUT.put_line ('Value of dep_id'||con_dep_id );
END LOOP;
DBMS_OUTPUT.put_line ('.....****************************...');
---- Here need to compare with check_test2 table for the active ness of the id in where condition i've to pass the con_dep_id
--- But how to differentiate For which parent the child is checking the childs
-- The invalid records( where for ex:do_up_id =100001 ) should be removed form test_tab Or the valid records can be copied to another associative array having the same structure as test_tab
END;
END;
EXEC TEST_PAK1.search_obj ('Hi');
I even confused with
SELECT test_tab(i).do_up_id ,wm_concat( CONNECT_BY_ROOT test_tab(i).do_id) INTO dep_up_id ,dep_id
because wm_concat gives me ' , ' sepearated values where they can't fit into dep_id variablecreating global temporary tables will be useful or not !!!
Plz help me
Edited by: smile on Jan 5, 2012 10:23 PMI've a table contains the following columns and the data
create table test_test2 (do_id_tp varchar2(32),do_id number ,do_up_tp varchar2(32),do_up_id number)
insert into test_test2 values('A_S',100170,'A_S',100001);
insert into test_test2 values('P_G',1001052,'P_G',100001);
insert into test_test2 values('A_S',1001054,'P_G',100001);
insert into test_test2 values('A_S',1001055,'P_G',100001);
insert into test_test2 values('P_G',1001037,'P_G',100001);
insert into test_test2 values('P_G',1001038,'P_G',100001);
insert into test_test2 values('A_S',1001053,'P_G',100001);
insert into test_test2 values('A_S',1001056,'P_G',100001);
insert into test_test2 values('A_S',1001052,'P_G',100001);
insert into test_test2 values('A_S',1001051,'P_G',100001);
insert into test_test2 values('P_G',100001,'R_S',100001);
insert into test_test2 values('P_G',1001031,'R_S',100001);
insert into test_test2 values('P_G',1001035,'R_S',100001);
insert into test_test2 values('A_S',100170,'P_G',100001);
insert into test_test2 values('A_S',1001054,'A_S',100001);
insert into test_test2 values('A_S',1001055,'A_S',100001);
insert into test_test2 values('A_S',1001053,'A_S',100001);
insert into test_test2 values('A_S',1001056,'A_S',100001);
insert into test_test2 values('A_S',1001051,'A_S',100001);
insert into test_test2 values('A_S',1001052,'A_S',100001);
insert into test_test2 values('A_S',100001,'P_G',100001);In the above data R_S is at high level (Means P_G and A_S should depend on R_S)
similarly P_G is next level ( A_S should depend on P_G OR P_G depends on P_G)
the lower level is A_S ( A_S depends on A_S)
So i tried the following query which gives the child list of a parent
SELECT DO_UP_TP,DO_UP_ID ,do_id_tp,wm_concat( CONNECT_BY_ROOT do_id)
FROM test_test2
where do_up_id=100001
CONNECT BY nocycle PRIOR do_up_id = do_id
group by DO_UP_TP,DO_UP_ID ,do_id_tp;The requirement is for each do_up_id ( i'll get a list of do_id (which are in wm_concat).).
i've to check in flag column in Following table
create table check_test2 (d_id ) as
select do_up_id from test_test2 union
select do_id from test_test2
alter table check_test2 add (flag char(1) DEFAULT 'N')For Ex: R_S (100001) has the childs P_G(100001),P_G(1001031),P_G(1001035) {This is a branch in a Tree}
Now first i've to check R_S(100001) is active or not in the check_test2 table, If 'N' then check it's child's flag until it finds no more childs.
If no child is having 'Y' then mark the entire branch as 'N'
This i've to do for all the do_up_id in TEST_TEST2 table.
I tried the following package plz correct me as per requirement
CREATE OR REPLACE package USPF_APR.test_pak1 as
FUNCTION map_object ( obj_typ_in VARCHAR2 ) RETURN VARCHAR2;
CURSOR c_c1
IS
select * from test_test2 where (do_id in (100001) or do_up_id in (100001));
TYPE test_ttyp IS TABLE OF c_c1%ROWTYPE INDEX BY PLS_INTEGER;
procedure search_obj(obj_type varchar2);
end;
CREATE OR REPLACE package body USPF_APR.test_pak1 as
FUNCTION map_object ( obj_typ_in VARCHAR2 ) RETURN VARCHAR2
IS
begin
dbms_output.put_line ('Hello');
return 'abc';
end;
PROCEDURE search_obj (obj_type VARCHAR2)
IS
test_tab test_ttyp;
test_tab_r c_c1%ROWTYPE;
dep_up_id NUMBER;
dep_id NUMBER;
con_dep_up_id VARCHAR2(2100);
con_dep_id VARCHAR2(2100);
BEGIN
OPEN c_c1;
LOOP
Fetch c_c1 into test_tab_r;
exit when c_c1%NOTFOUND;
test_tab(test_tab.COUNT + 1) := test_tab_r;
END LOOP;
CLOSE c_c1;
DBMS_OUTPUT.put_line ('Test_tab.count is ...'|| test_tab.COUNT);
FOR i IN 1 .. test_tab.COUNT LOOP
WITH T AS
( SELECT test_tab(i).do_id , test_tab(i).do_up_id
FROM DUAL)
SELECT test_tab(i).do_up_id ,wm_concat( CONNECT_BY_ROOT test_tab(i).do_id) INTO dep_up_id ,dep_id
FROM T
CONNECT BY nocycle PRIOR test_tab(i).do_up_id=test_tab(i).do_id
group by test_tab(i).do_up_id;
con_dep_id := con_dep_id || ',' || dep_id;
DBMS_OUTPUT.put_line ('Value of dep_id'||con_dep_id );
END LOOP;
DBMS_OUTPUT.put_line ('.....****************************...');
---- Here need to compare with check_test2 table for the active ness of the id in where condition i've to pass the con_dep_id
--- But how to differentiate For which parent the child is checking the childs
-- The invalid records( where for ex:do_up_id =100001 ) should be removed form test_tab Or the valid records can be copied to another associative array having the same structure as test_tab
END;
END;
EXEC TEST_PAK1.search_obj ('Hi');
I even confused with
SELECT test_tab(i).do_up_id ,wm_concat( CONNECT_BY_ROOT test_tab(i).do_id) INTO dep_up_id ,dep_id
because wm_concat gives me ' , ' sepearated values where they can't fit into dep_id variablecreating global temporary tables will be useful or not !!!
Plz help me
Edited by: smile on Jan 5, 2012 10:23 PM -
Need help on one odd query results...
Hi Guys,
I need your help,
Requirement is :- Suppose we have got Below titles in one table :-
HULK
THE INCREDIBLE HULK - 2001 (DO NOT USE)
REVERSE HULK
INCREDIBLE HULK U/A
BRING ME HEAD OF THE HULK
JENNIFER JASON LEIGH, HULK HOGAN
HULK 2
BRIDE OF THE INCREDIBLE HULK
HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
INCREDIBLE HULK #03 (1979/80)
HULK HOGAN'S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)
Now the requirement is :-
O/p Should be in below order without have duplicate records
HULK first then
HULK % then
%HULK%.
O/p :-
HULK
HULK 2
HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
HULK HOGAN'S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)
THE INCREDIBLE HULK - 2001 (DO NOT USE)
REVERSE HULK
INCREDIBLE HULK U/A
BRING ME HEAD OF THE HULK
JENNIFER JASON LEIGH, HULK HOGAN
BRIDE OF THE INCREDIBLE HULK
INCREDIBLE HULK #03 (1979/80)
How can we do it using sql query ? Is it possible to do it one query?
Or need to use PL/SQL table etc?
There should be no duplicate if we use more than one query or single query ..
Can you help?tappusingh wrote:
O/p Should be in below order without have duplicate records
HULK first then
HULK % then
%HULK%. Maybe something like:
SQL> WITH test_tab
2 AS (SELECT 'HULK' col FROM DUAL
3 UNION ALL
4 SELECT 'THE INCREDIBLE HULK - 2001 (DO NOT USE)' FROM DUAL
5 UNION ALL
6 SELECT 'REVERSE HULK' FROM DUAL
7 UNION ALL
8 SELECT 'INCREDIBLE HULK U/A' FROM DUAL
9 UNION ALL
10 SELECT 'BRING ME HEAD OF THE HULK' FROM DUAL
11 UNION ALL
12 SELECT 'JENNIFER JASON LEIGH, HULK HOGAN' FROM DUAL
13 UNION ALL
14 SELECT 'HULK 2' FROM DUAL
15 UNION ALL
16 SELECT 'BRIDE OF THE INCREDIBLE HULK' FROM DUAL
17 UNION ALL
18 SELECT 'HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD' FROM DUAL
19 UNION ALL
20 SELECT 'INCREDIBLE HULK #03 (1979/80)' FROM DUAL
21 UNION ALL
22 SELECT 'HULK HOGAN''S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)'
23 FROM DUAL)
24 -- " end of test data "
25 SELECT DISTINCT col
26 FROM test_tab
27 ORDER BY CASE
28 WHEN col = 'HULK' THEN 1
29 WHEN col LIKE 'HULK%' THEN 2
30 WHEN col LIKE '%HULK%' THEN 3
31 ELSE 4
32 END, col
33 /
COL
HULK
HULK 2
HULK HOGAN'S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)
HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
BRIDE OF THE INCREDIBLE HULK
BRING ME HEAD OF THE HULK
INCREDIBLE HULK #03 (1979/80)
INCREDIBLE HULK U/A
JENNIFER JASON LEIGH, HULK HOGAN
REVERSE HULK
THE INCREDIBLE HULK - 2001 (DO NOT USE)
11 rows selected.
SQL>Regards,
Jo -
Need to tune the hierarchical query
Hi Guys,
Can you guys tune in the possible ways...as this is taking 30-40 sec.. No indexes on this table as of now.
SELECT org_id,
parent_id,
organization,
(SELECT LISTAGG(parent_id, ', ') WITHIN GROUP( ORDER BY org_id)
FROM organization_master where org_id in(SELECT org_id
FROM organization_master
START WITH org_id = a.org_id
CONNECT BY NOCYCLE prior parent_id = org_id))
FROM t_org a
WHERE upper(organization) like upper('%Greater%');
Thanks in advance!
Rgds,
LrkSo this is a VIEW with I think 18 tables (I may have missed one or two), some of which are referenced more than one. Some of these tables have tens of miilions of rows. What exactly are you expecting from us?
I guess this is a data warehouse or BI query. Sometimes such queries just take an age to run and there's nothing which can be done except result caching. Other times the queries can be tuned, but iit requires way more context and domain knowledge than you have provided.
Please start by reading [url https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360003]this FAQ. .
Cheers, APC -
How to get Query Results based on Analysis Authorization Ranges????
Hi Experts,
I have gone through the lot of SDN Links, however not able to find the answer to my question.
I have an Authorization Issue, NO Authorization
Error : EYE 007 ( Insufficient Authorizations )
<b>Here is the issue:</b>
Need to see the complete query result when I gave the range in Analysis Authorization for Controlling Area 001-005. Controlling Area is auth relevant and right now a variable is inserted in the query for it. If I select Controlling Area 001, the result for Controlling Area 001 is displayed in query. If 002 then also displayed. If I do not enter anything, then I get the <b>Eye 007 error message</b>.
I am not sure how do I display/authorize the entire result in the query for all the Controlling Areas, I have authorized user to see??
<b>Its really urgent, please help..!</b>
Here are the logs:
Authorization Check Log
Date and Execution Time (Local Server)
Execution Date: 06.09.2007
Execution Time: 14:48:41
Executed Query: 0CCA_C11/GBCCA_MP01_Q0002_AP
Executed by User ZBI_TEST_001
Executed with Analysis Authorizations of Another User ZBI_TEST_001
InfoProvider Check
Building the Buffer...
...Buffer Built
Are there authorizations for accessing InfoProvider 0CCA_C11 with activity 03?
Authorization exists for general access to InfoProvider 0CCA_C11 with activity 03
InfoProvider Check
Authorization exists for general access to InfoProvider 0CCA_C11 with activity 03
Relevant Characteristics for Detailed Authorization Check
(Characteristics with Full Authorization Are Not Listed!)
List of Effective Authorization-Relevant Characteristics for InfoProvider 0CCA_C11:
0CO_AREA
0TCAACTVT
Relevant Characteristics for Detailed Authorization Check
(Characteristics with Full Authorization Are Not Listed!)
List of Effective Authorization-Relevant Characteristics for InfoProvider :
List Is Empty:
There Are No Characteristics That Have to Be Checked in Detail
Authorization Check
Detail Check for InfoProvider 0CCA_C11
Preprocessing:
Selection Checked for Consistency, Preprocessed and Supplemented As Needed
Subselection (Technical SUBNR) 1
Check Node Definitions and Value Authorizations...
Node- and Value Authorizations Are OK
End of Preprocessing
Filling the Buffer...
...Buffer Filled
Main Check:
Subselection (Technical SUBNR) 1
Supplementation of Selection for Aggregated Characteristics
No Check for Aggregation Authorization Required
Following Set Is Checked Comparison with Following Authorized Set Result Remaining Set
Characteristic Contents
0CO_AREA
0TCAACTVT
SQL Format:
CO_AREA = '0003'
AND TCAACTVT = '03'
Characteristic Contents
0CO_AREA I BT 0001 0005
0TCAACTVT I EQ 03
I EQ 16
Authorized
Subselection (SUBNR) Is Authorized
Authorization Check Complete
Authorization Check
Detail Check for InfoProvider 0CCA_C11
Preprocessing:
Selection Checked for Consistency, Preprocessed and Supplemented As Needed
Subselection (Technical SUBNR) 1
Check Node Definitions and Value Authorizations...
Node- and Value Authorizations Are OK
End of Preprocessing
Filling the Buffer...
...Buffer Filled
Main Check:
Subselection (Technical SUBNR) 1
Supplementation of Selection for Aggregated Characteristics
No Check for Aggregation Authorization Required
Following Set Is Checked Comparison with Following Authorized Set Result Remaining Set
Characteristic Contents
0CO_AREA
0TCAACTVT
SQL Format:
TCAACTVT = '03'
Characteristic Contents
0CO_AREA I BT 0001 0005
0TCAACTVT I EQ 03
I EQ 16
Partially or Fully Authorized (Intersection) Characteristic Contents
0CO_AREA
0TCAACTVT
SQL Format:
( CO_AREA < '0001'
OR CO_AREA > '0005' )
AND TCAACTVT = '03'
Value selection partially authorized. Check of remainder at end
Following Set Is Checked Comparison with Following Authorized Set Result Remaining Set
Characteristic Contents
0CO_AREA
0TCAACTVT
SQL Format:
( CO_AREA < '0001'
OR CO_AREA > '0005' )
AND TCAACTVT = '03'
Characteristic Contents
0CO_AREA I BT 0001 0005
0TCAACTVT I EQ 03
I EQ 16
Not Authorized
All Authorizations Tested
Message EYE007: You do not have sufficient authorization
No Sufficient Authorization for This Subselection (SUBNR)
Following CHANMIDs Are Affected:
184 ( 0CO_AREA )
Authorization Check CompleteHi,
Have you defined the vaule for 0CO_AREA as BT 001-005 in you Authorization for 0CO_AREA.Also how have you defined your Authorization Variable on the query? Have you define as select options or interval? I thing you need to define it as interval or select options.
Hope it helps,
Cheers,
Balaji -
How to save query result on the file server as excel file?
Hi everyone,
I need to save the the query result on the file server as excel file.
Do you have any idees how can I do it?
Regards
Erwini dont think you can save as excel file but you can save it as CSV use APD or RSCRM BAPI for this
-
Broadcasting the precalculated query results in web format
Hi Experts,
We have a requirement where we need to broadcast the precalculated query results in web format, we know that we can do this through workbook, but we want to do it in web format to avoid the limitations of the workbook like number of rows in workbook limited to 65000 etc.,
We are using 3.x environment,
please suggest that is this functionality can be achievable, if yes how?
Thanks in advance,
-VinayHi All, this problem was resolved.
Thanks,
vinay -
hello all,
i have a form having master and detail block. in master we have store_cd and location code(primary key in master table),
based on that detail recrds fetch in detail block. perfectly fine. but when i query within detail block records then it show no record found. please tell me what can be wrong.
detail table primary key is (store_cd, location_code and storage_co) , in realtion i mentioned
masterblock.store_cd=detailblock.store_cd and masterblock.location_cd=detailblock.location_cd
Thanks
yashyes, there are records in detail table... table structure(master and detail block)
SQL> desc ivt_store_mst
Name Null? Type
STORE_CD NOT NULL VARCHAR2(3)
STORE_DESC NOT NULL VARCHAR2(25)
LVL_REF_CD NOT NULL VARCHAR2(6)
STORE_TYPE VARCHAR2(2)
Primary key(store_cd,lvl_ref_cd)
SQL> desc ivt_storg_mst;
Name Null? Type
STORE_CD NOT NULL VARCHAR2(3)
STORAGE_SRL_NO NOT NULL NUMBER(10)
STORAGE_CD VARCHAR2(10)
ITEM_CD NOT NULL VARCHAR2(10)
BAY_NO VARCHAR2(10)
SHELF_NO VARCHAR2(10)
ROW_NO VARCHAR2(10)
TIER_NO VARCHAR2(10)
BIN_CARD_NO VARCHAR2(10)
INSERT_DT DATE
GRN_NO VARCHAR2(12)
GRN_FIN_YR_CD VARCHAR2(8)
PLEVEL_REF_CD NOT NULL VARCHAR2(6)
PGRN_LEVEL_REF_CD VARCHAR2(6)
Primary key(store_cd,storage_cd, plevel_ref_cd)
relation property is: noo-isolated
deferred: false
autoquery: false
block join condition based on detail_blk1.stor_cd=masteblk.store_cd
when i query from master block , ALL detail blocks ITEMS are displaying. but when i query again among detail block items then, no record found base on query field(detail blk: item_cd which is base table field).
when i query in detail block for all records then Every time only one item display with same item_cd...
if further some info required, plz mention -
Too many results in hierarchically query
Hello all,
I'm searching for an idea to stop getting results 2, 3 and more times out of the following query
select
t.lvl,
t.syswflvl,
t.upper,
LPAD(' ', (lvl)*8)||t.code code,
LPAD(' ', (lvl)*8)||t.bezeichnung bezeichnung,
t.chk,
t.rang
from (
select '0' lvl, '0-'||to_char(syswftable,'0000000') syswflvl, '0- 0000000' upper, syscode code, bezeichnung, '' chk, 0 rang from wftable where (select count(wfm.syswftable) from wfm where wfm.syswftable = wftable.syswftable) > 0 union
select '1' lvl, '1-'||to_char(syswfm,'0000000') syswflvl, '0-'||to_char(syswftable,'0000000') upper, syscode code, kurzbez bezeichnung, anzeigefilter chk, 1 rang from wfm union
select '2' lvl, '2-'||to_char(syswfa,'0000000') syswflvl, '1-'||to_char(syswfm,'0000000') upper, syscode code, kurzbez bezeichnung, bedingung chk, rang from wfa union
select '3' lvl, '3-'||to_char(syswfc,'0000000') syswflvl, '2-'||to_char(syswfa,'0000000') upper, syscode code, kurzbez bezeichnung, bedingung chk, rang from wfc union
select '4' lvl, '4-'||to_char(syswfg,'0000000') syswflvl, '3-'||to_char(syswfc,'0000000') upper, syscode code, kurzbez bezeichnung, bedingung chk, rang from wfg
) t
where ((t.chk not like '%and 0%'
and trim(t.chk) not like '0%')
or t.chk is null)
and upper not like '%-'
connect by nocycle prior syswflvl = upper
order siblings by upper, syswflvl, rang
What happens is, that I get the results from level 0 one times, from level 1 two times, from level 2 three times etc.
What I'm try to achive is to get only the whole thing once.
Hope you can see what my problem is ;-)
Regards
CarstenThe effect of not having a start with clause in a hierarchical query is that a hierarchy is produced starting at every possible entry-point. So, you'll get the hierachy from node 1, the hierarchy from all nodes 2, the hierarchy from all nodes 3 and so one. Whether it starts with the correct one or not is not really relevant, as you already figured out that you get too much....
So, just believe it, add a start with clause...and your problems are gone. -
[Oracle 8i] Need help pruning branches from a hierarchical query
My problem is that my hierarchical query seems only to trim out the values that don't meet my criteria, but still includes their children. When my query hits a record that does not meet my criteria, I want it to stop there. I've tried including the criteria in just the 'where' clause of the query, and have also put the criteria in the 'connect by' clause as well, but nothing has fixed it. Please keep in mind I'm using Oracle 8i, so I can't use some of the 'nicer' statements for hierarchical queries that they introduced in 9. I'm stuck with 'Start With...Connect By'.
I have sample tables/data that I can post if someone needs to see that to help me, but to start with, here's my current query:
SELECT *
FROM (
SELECT
LEVEL
, c_bill.comp_part_nbr AS c_part_nbr
, (select c_part.part_desc
FROM part c_part
WHERE c_part.part_nbr=c_bill.comp_part_nbr) AS c_part_desc
, (SELECT c_part.part_type
FROM part c_part
WHERE c_part.part_nbr=c_bill.comp_part_nbr) AS c_part_type
, c_bill.qty_per AS c_qty_per_p
, c_bill.qty_per_type AS c_qty_per_type
, (SELECT c_part.qty_on_hand
FROM part c_part
WHERE c_part.part_nbr=c_bill.comp_part_nbr) AS c_qty_on_hand
, c_bill.oper_nbr AS rqd_at_op
, c_bill.comp_off_adj AS rqd_offset
, c_bill.bom_doc_nbr AS p_part_nbr
, (SELECT p_part.qty_on_hand
FROM part p_part
WHERE p_part.part_nbr=c_bill.bom_doc_nbr) AS p_qty_on_hand
FROM
BILL c_bill
WHERE
(c_bill.status = 'RL')
AND (c_bill.view_code IN ('M','G'))
AND (c_bill.end_eff_dt > SYSDATE)
AND (c_bill.begn_eff_dt <= SYSDATE)
START WITH c_bill.bom_doc_nbr=RPAD(?,25)
CONNECT BY PRIOR c_bill.comp_part_nbr=c_bill.bom_doc_nbr
AND c_bill.view_code IN ('M','G')
AND c_bill.status = 'RL'
AND c_bill.end_eff_dt > SYSDATE
AND c_bill.begn_eff_dt <= SYSDATE
) a
WHERE c_part_type = 'M'The outside criterion of part_type='M' isn't my problem. Where I'm actually seeing my issue rear its ugly head is in the criterion:
(c_bill.view_code IN ('M','G'))What I'll have happen is that one of the children or grandchildren of the part number I'm querying for (my parameter), will be of some view code that's not 'M' or 'G'. In my sample data below, I have a level 4 part that is part of the 'H' view code, which I don't want, nor do I want it's children. However, its child is in the 'G' view code, and my query returns it anyway.
In my sample data below, I'm assuming that the parameter = 'XYZ-100'
CREATE TABLE part
part_nbr varchar(25) not null,
part_desc varchar(25) not null,
part_type char(1) not null,
qty_on_hand double(13,4) not null
CONSTRAINT part_pk
PRIMARY KEY (part_nbr),
CONSTRAINT check_part_type
CHECK (part_type IN ('M','P','X','Y')),
CONSTRAINT check_qty_on_hand
CHECK (qty_on_hand >= 0)
CREATE TABLE bill
row_added_ts char(20) not null,
bom_doc_nbr varchar(25) not null,
comp_part_nbr varchar(25) not null,
qty_per double(9,5) not null,
qty_per_type char(1) not null,
oper_nbr char(4) not null,
comp_off_adj double(3,0),
status char(2),
view_code char(1) not null,
end_eff_dt date() not null,
begn_eff_dt date() not null
CONSTRAINT bill_pk
PRIMARY KEY (row_added_ts),
CONSTRAINT check_qty_per_type
CHECK (qty_per_type IN ('0','1','2','3')),
CONSTRAINT check_status
CHECK (status IN ('IN', 'RL')),
); Values for those tables:
INSERT INTO part
VALUES ('xyz-1', 'purchased part', 'P', 5);
INSERT INTO part
VALUES ('xyz-2', 'purchased part', 'P', 1);
INSERT INTO part
VALUES ('xyz-3', 'purchased part', 'P', 1);
INSERT INTO part
VALUES ('xyz-3a', 'manufactured part', 'M', 1);
INSERT INTO part
VALUES ('xyz-4', 'purchased part', 'P', 1);
INSERT INTO part
VALUES ('xyz-9-1', 'manufactured part', 'M', 0);
INSERT INTO part
VALUES ('xyz-9a', 'manufactured part', 'M', 0);
INSERT INTO part
VALUES ('raw-1', 'purchased raw material', 'P', 212);
INSERT INTO part
VALUES ('raw-2', 'purchased raw material', 'P', 75.5);
INSERT INTO part
VALUES ('XYZ-100', 'manufactured part', 'M', 0);
INSERT INTO part
VALUES ('(OPEN)', '(not in use)', 'Y', 0);
INSERT INTO part
VALUES ('XYZ-100-1', 'manufactured part', 'M', 0);
INSERT INTO part
VALUES ('XYZ-100-2', 'manufactured part', 'M', 1);
INSERT INTO part
VALUES ('XYZ-100-3', 'manufactured part', 'M', 0);
INSERT INTO part
VALUES ('XYZ-100-4', 'manufactured part', 'M', 2);
INSERT INTO part
VALUES ('XYZ-100-A', 'manufactured part', 'M', 0);
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100','xyz-1',3,'1','****',0,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100','XYZ-100-1',1,'1','****',0,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-1','xyz-1',2,'1','****',1,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-1','XYZ-100-2',3,'1','****',0,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-2','xyz-2',6,'1','****',2,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-2','xyz-4',6,'1','****',2,'IN','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-2','xyz-100-3',1,'1','****',0,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-3','xyz-3',8,'1','****',1,'RL','M','01-Jan-2050','01-Jan-2000');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-3','xyz-3a',8,'1','****',1,'RL','M','01-Jan-2000','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-3','XYZ-100-4',4,'1','****',0,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-3','XYZ-100-A',2,'1','****',2,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008071153100150000','XYZ-100-3','(OPEN)',2,'1','****',0,'RL','E','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008071153100150000','XYZ-100-3','xyz-9-1',2,'1','****',0,'RL','H','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-4','raw-1',8.75,'1','****',0,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008072153100150000','XYZ-100-A','raw-2',3.75,'1','****',0,'RL','M','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008075911100150000','xyz-9-1','xyz-9a',1,'1','****',0,'RL','G','01-Jan-2050','01-Jan-1900');
INSERT INTO bill
VALUES ('2008087711100150000','xyz-9a','raw-2',3.75,'1','****',0,'RL','G','01-Jan-2050','01-Jan-1900');Sample data displayed in table format:
--PART table (from insert statements above)
part_nbr part_desc part_type qty_on_hand
xyz-1 purchased part P 5
xyz-2 purchased part P 1
xyz-3 purchased part P 1
xyz-3a manufactured part M 1
xyz-4 purchased part P 1
xyz-9-1 manufactured part M 0
xyz-9a manufactured part M 0
raw-1 purchased raw material P 212
raw-2 purchased raw material P 75.5
XYZ-100 manufactured part M 0
(OPEN) (not in use) Y 0
XYZ-100-1 manufactured part M 0
XYZ-100-2 manufactured part M 1
XYZ-100-3 manufactured part M 0
XYZ-100-4 manufactured part M 2
XYZ-100-A manufactured part M 0
--BILL table (from insert statements above)
row_added_ts bom_doc_nbr comp_part_nbr qty_per qty_per_type oper_nbr comp_off_adj status view_code end_eff_dt begn_eff_dt
2008072153100150000 XYZ-100 xyz-1 3 1 **** 0 RL G 01-Jan-2050 01-Jan-1900
2008072223100150000 XYZ-100 XYZ-100-1 1 1 **** 0 RL M 01-Jan-2050 01-Jan-1900
2008072411100150000 XYZ-100-1 xyz-1 2 1 **** 1 RL M 01-Jan-2050 01-Jan-1900
2008072459100150000 XYZ-100-1 XYZ-100-2 3 1 **** 0 RL M 01-Jan-2050 01-Jan-1900
2008072578100150000 XYZ-100-2 xyz-2 6 1 **** 2 RL M 01-Jan-2050 01-Jan-1900
2008072694100150000 XYZ-100-2 xyz-4 6 1 **** 2 IN G 01-Jan-2050 01-Jan-1900
2008072786100150000 XYZ-100-2 xyz-100-3 1 1 **** 0 RL M 01-Jan-2050 01-Jan-1900
2008072865100150000 XYZ-100-3 xyz-3 8 1 **** 1 RL M 01-Jan-2050 01-Jan-2000
2008073100100150000 XYZ-100-3 xyz-3a 8 1 **** 1 RL M 01-Jan-2000 01-Jan-1900
2008073159100150000 XYZ-100-3 XYZ-100-4 4 1 **** 0 RL M 01-Jan-2050 01-Jan-1900
2008073346100150000 XYZ-100-3 XYZ-100-A 2 1 **** 2 RL M 01-Jan-2050 01-Jan-1900
2008073478100150000 XYZ-100-3 (OPEN) 2 1 **** 0 RL E 01-Jan-2050 01-Jan-1900
2008073529100150000 XYZ-100-3 xyz-9-1 2 1 **** 0 RL H 01-Jan-2050 01-Jan-1900
2008073798100150000 XYZ-100-4 raw-1 8.75 1 **** 0 RL M 01-Jan-2050 01-Jan-1900
2008073811100150000 XYZ-100-A raw-2 3.75 1 **** 0 RL M 01-Jan-2050 01-Jan-1900
2008075911100150000 xyz-9-1 xyz-9a 1 1 **** 0 RL G 01-Jan-2050 01-Jan-1900
2008087711100150000 xyz-9a raw-2 3.75 1 **** 0 RL G 01-Jan-2050 01-Jan-1900--What I want to get with my query (branches pruned off my tree)
LEVEL C_PART_NBR C_PART_DESC C_PART_TYPE C_QTY_PER_P C_QTY_PER_TYPE C_QTY_ON_HAND RQD_AT_OP RQD_OFFSET P_PART_NBR P_QTY_ON_HAND
1 XYZ-100-1 manufactured part M 1 1 0 **** 0 XYZ-100 0
2 XYZ-100-2 manufactured part M 3 1 1 **** 0 XYZ-100-1 0
3 xyz-100-3 manufactured part M 1 1 0 **** 0 XYZ-100-2 1
4 XYZ-100-4 manufactured part M 4 1 2 **** 0 XYZ-100-3 0
4 XYZ-100-A manufactured part M 2 1 0 **** 2 XYZ-100-3 0--What I actually get with my query (includes children of items that don't meet query criteria)
LEVEL C_PART_NBR C_PART_DESC C_PART_TYPE C_QTY_PER_P C_QTY_PER_TYPE C_QTY_ON_HAND RQD_AT_OP RQD_OFFSET P_PART_NBR P_QTY_ON_HAND
1 XYZ-100-1 manufactured part M 1 1 0 **** 0 XYZ-100 0
2 XYZ-100-2 manufactured part M 3 1 1 **** 0 XYZ-100-1 0
3 xyz-100-3 manufactured part M 1 1 0 **** 0 XYZ-100-2 1
4 XYZ-100-4 manufactured part M 4 1 2 **** 0 XYZ-100-3 0
4 XYZ-100-A manufactured part M 2 1 0 **** 2 XYZ-100-3 0
5 xyz-9a manufactured part M 1 1 0 **** 0 xyz-9-1 0Edited by: user11033437 on Jul 30, 2009 7:27 AM (grammar) -
Need blnak line in query result
In sqlplus query result, i need a blank line between each row. how can I get it? solution please.
There are various ways...
If you actually want generated blank rows...
SQL> ed
Wrote file afiedt.buf
1 select decode(rn, 1, empno) as empno
2 ,decode(rn, 1, ename) as ename
3 ,decode(rn, 1, job) as job
4 ,decode(rn, 1, mgr) as mgr
5 ,decode(rn, 1, hiredate) as hiredate
6 ,decode(rn, 1, sal) as sal
7 ,decode(rn, 1, comm) as comm
8 ,decode(rn, 1, deptno) as deptno
9 from emp, (select rownum as rn from dual connect by rownum <= 2) r
10* order by emp.empno, r.rn
SQL> /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
1111 WILLIS CLERK 7902 18-JAN-08 900 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
30 rows selected.
SQL> -
Only overall result need tp be displayed after query execution
Hello Everyone,
I am requirement on query analysis " OVERALL RESULTS". The scenario is explained below.
I am dealing with BW HR Reporting. Now if i execute the query from 2008. 01 to 2008 03. The Result will be displayed for 2008.01, 2008.02, 2008.03. and atlast the overall result. The requirement is , after executing the query for the calday 2008.01. to 2008.03 , i need to get only the OVERALL RESULT". The details of the individauls months will be taken care at the jump target level.
Can somebody give th inputs from your end, so that only the overall results will be displayed.
Appreciate your immediate response. Thanks in advance.
Regards,
pradeepHi
How about suppress results on the characteristic properties
Regards -
I need to print one query result as a single row
Hi,
I need to print one query result as a single row ,which gives more than one value (of subinventories)and also i would like to print the quantity of that particular subinventory at particular place.Please suggest how can i do this in the report builder?Actually I need to print inventory report with subinventory break up.For that all subinventories of category code AB are taken as single row.Based on that subinventory value Quantity must be printed at that particular place.
For ex
Quantity
Item no Description Subinventory Code AB_Abc AB_Def AB_ghi
1 ***** 12 9
2 ****** 8 5
like that.I am waiting for the reply.Plz its some how urgent.
Thank you, -
Dear Experts,
I am having the following requirement.
Can it be possible to present the QUERY result in Graph ?
I read many thread in SDN, I found through APD/WAD we can do it . But I am confused.
But I am not getting any thread , How to proceed step by step ?
Kindly help..
Thanks,
SethiHi,
If you are using Bex Query make as work book ,in that you can add charts and save as work book not as a query.
To insert the chart
Go to insert tab in the Excel(Work book) choose which chart you want in that.
After that go the chart which you have selected, right click and go to select data option, choose series for Entries and choose labels for category.
Hope it helps.
Thanks & Regards,
Ramnaresh.P. -
Need help on retrieving query result - NPE
Hi, I could get results with the native query in my TOAD, but I can't get it working in my session EJB. I tried both native query and EJB ql. The query created fine, as soon as I try to retrieve results, it gets stuck.
My native query looks like this:
Query query = em.createNativeQuery("select sum(o.amount_reimbursed) from t_expenses o where o.employee_id = '999999911' " +
"and o.EXPENSE_ID in (select p.expense_id from T_Per_Diem_Xref p where p.expense_Type_Xref_Id=22 " +
"and p.expense_Id in (select e.expense_Id from T_Expenses e where e.employee_Id='999999911' " +
"and e.expense_date > to_date('01/01/2011', 'mm/dd/yyyy') and e.expense_date < to_date('12/31/2011', 'mm/dd/yyyy')))") ;
My EJB query looks like this:
Query query = em.createQuery("select sum(o.amountReimbursed) from TExpenses o where o.employeeId = ?1 " +
"and o.expenseId in (select p.expenseId from TPerDiemXref p where p.expenseTypeXrefId=?2 " +
"and p.expenseId in (select e.expenseId from TExpenses e where e.employeeId=?1 and e.expenseDate>=?3 and e.expenseDate<=?4))");
query.setParameter(1, employeeId);
query.setParameter(2, expenseType);
query.setParameter(3, fDay, TemporalType.TIMESTAMP);
query.setParameter(4, lDay, TemporalType.TIMESTAMP);
Either one, I get NPE at the line retrieve result.
// sumAmt = (Double)query.getSingleResult();
List list = query.getResultList();
if (list != null) {
long longAmt = (Long)list.get(0);
sumAmt = (Double)list.get(0);
As you can see, I tried to getSingleResult, or getResultList. also tried to convert the result to Double or Long. None worked.
Please help and thank you for your time.
SophiaFrank, thank you for your reply. I have this code in my session Facade EJB, and I get the NPE in my backing bean which calls this method. When I debug the code, it appears what really cuases the problem is in this code on the line I try to assign the query result to my variable 'sumAmt = (Double)query.getSingleResult();'. In the debug, when it reaches this line, it starts to give me all kinds of pop-up windows saying couldn't find this file or that file or packages. If I get a stack trace later, I will post it. Right now I am trying to fix something else.
Thanks, Sophia
Maybe you are looking for
-
Never tried to load a flash movie before. Should be a no brainer, but for some reason when I select the movie from the insert flash video menu "test.swf" I get a path error. I moved all my files to C:\test\ but still get the same ridiculous error. Wh
-
Webdynpro for abap using portal theme nw2004s, sp12
Hello, we use on instance 03 portal on netweaver2004s, sp12, which calls webdynpros with iview for abap on intstance 02, where ist netweaver 2004s sp12, abap stack. The problem is that the webdynpro is no more rendered with portaltheme. In the prevoi
-
Wireless contection working but connection on main computer not working
I was using my main computer last night and walked away from it for about 15 minutes. When I came back it said there wasn't a connection to the internet and couldn't find one. I restarted the router and computer but it did not help. The connection
-
How do I remove password from iphone
How do I remove login password after it has been set up? I tried to turn password off but the option was grayed out.
-
IPhone screen won't flip horizontally for videos
After I upgraded my iPhone 5 to iOS 7 my screen won't flip horizontally for video clips. It does flip for YouTube but not for music videos. Please fix!!