Discoverer 3.1 query governor help
I'm trying to schedule some queries in discoverer through a
batch file with command line entries. My batch file works, but I
can't get all my data back. I am assuming that the queries are
using a default setting for the query governor(10,000). I have
about 200,000 records I'm trying to return. Is there a parameter
on the command line I can use to return all records? I am not
running an administrator version.
Hi,
Are these joins defined as outer joins in the EUL? Did you have the DisableAutoOuterJoinsOnFilters set on the old environment?
Do you have multiple detail folders in the worksheet from the same master folder?
Rod West
Similar Messages
-
Discoverer 4i: GL Query caused no data to be received
Hi,
E-Business 11.5.10.2 on Windows Server 2003 SP2
Discoverer 4i
I've set up Discoverer 4i and am currently using Discoverer Desktop to query the business areas. I can retrieve data from any business area apart from GL.
When I attempt to query GL I get an error message stating 'Query caused no data to be received'.
Has anyone encountered this before? Any help greatly appreciated.
Thanks,
MarkHi,
It could be that these GL folders use row level security and the gl_security_pkg is not initialized.
Try creating a custom folder containing:
select gl_security_pkg.login_sob_id from dualLog in with the UK GL User responsibility and create a workbook based on this custom folder. If this returns a null row then the GL package is not properly initialized. Check that the "GL Set of Books ID" system profile is set for the responsibility. You can initilalize the package manually by adding the following text into the the "Initialization SQL Statement - Custom" system profile for the responsibility:
begin
gl_security_pkg.init;
end;Hope that helps,
Rod West -
How to improve the performance of the attached query, Please help
Hi,
How to improve performance of the below query, Please help. also attached explain plan -
SELECT Camp.Id,
rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount,
(SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
rCam.AccountKey as AccountKey
FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
WHERE Camp.AccountKey = rCam.AccountKey
AND Camp.AvCampaignKey = rCam.AvCampaignKey
AND Camp.AccountKey = CamBilling.AccountKey
AND Camp.CampaignKey = CamBilling.CampaignKey
AND rCam.AccountKey = xSite.AccountKey
AND rCam.AvSiteKey = xSite.AvSiteKey
AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
to_date('01-01-2011', 'DD-MM-YYYY')
GROUP By rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount
Explain Plan :-
Description Object_owner Object_name Cost Cardinality Bytes
SELECT STATEMENT, GOAL = ALL_ROWS 14 1 13
SORT AGGREGATE 1 13
VIEW GEMINI_REPORTING 14 1 13
HASH GROUP BY 14 1 103
NESTED LOOPS 13 1 103
HASH JOIN 12 1 85
TABLE ACCESS BY INDEX ROWID GEMINI_REPORTING RCAMSIT 2 4 100
NESTED LOOPS 9 5 325
HASH JOIN 7 1 40
SORT UNIQUE 2 1 18
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY SITE 2 1 18
INDEX RANGE SCAN GEMINI_PRIMARY SITE_I0 1 1
TABLE ACCESS FULL GEMINI_PRIMARY SITE 3 27 594
INDEX RANGE SCAN GEMINI_REPORTING RCAMSIT_I 1 1 5
TABLE ACCESS FULL GEMINI_PRIMARY CAMPAIGN 3 127 2540
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY CAMBILLING 1 1 18
INDEX UNIQUE SCAN GEMINI_PRIMARY CAMBILLING_U1 0 1Hello,
This has really nothing to do with the Oracle Forms product.
Please, send the SQL or/and PL/SQL questions in the corresponding forums.
Francois -
Cluster bar chart- sql query please help-
Hi,
I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
Here is my table
city region issue value
c1 north i1 y
c1 north i2 y
c2 north i1 n
c2 north i2 y
c3 south i1 y
c3 south i2 n
c4 east i1 n
c4 east i2 n
The bar chart will have 3 series, north south and east.
And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
How can I get something like this from the above table-
region issue count(yes)
north i1 1
north i2 2
south i1 1
south i2 0
east i1 0
east i2 0
thanksWITH table1 AS
(SELECT 1435177 qte_id, 2 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no
FROM dual
table2 AS
SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
FROM dual
SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
FROM
(SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
FROM table1 t1, table2 t2
WHERE t2.qte_id = t1.qte_id (+)
AND t2.seq_no = t1.seq_no(+)
ORDER BY 1,2
WHERE t1_seq_no IS NOT NULL
ORDER BY 1,2
QTE_ID T2_SEQ_NO DIFF
1435177 2 0
1435177 5 0
1435177 7 0
1435177 8 0
1435177 12 0
1435177 14 0 -
Discoverer Query please help me....
In our application we have created a user table through which application access is given to the users. Due to this the user has limited access of the application data.
For example –
User A has rights for entering purchase order of department A. So he only view purchase orders of department A.
Is there any way in which restricted data access can be given in Discoverer. (Referring the above example)
If there please let me know.And I'll add another 3cents to what Puppethead said.
This is one of those age ol' aguments between tech-types (us) and DBAs (them) - okay, I'm sure there's some DBAs on this forum.
As Puppethead says, a view is nothing more than a SQL statement, and if you think about it, you're just wrapping a CREATE OR REPLACE VIEW AS ... statement around the exact same SQL statement.
Additionally, just for some more info, Oracle Apps, BIS, NoetixViews, etc. have literally thousands upon thousands of views, so I'll side with Oracle.
Would adding a middle thingy (computer term) around a SQL statement make a difference in run time? I suppose it's an extra weight so I'll add 1/2 nano-second or so. But as pointed out already, a badly written view - like a badly written SQL statement may add 1/2 hour to a query.
Views ... luv 'em.
Russ -
hi,
i need some help in trying to create a query to show the table_name, mb_used and degree of parallelism.
this is what i currently have..
SELECT a.segment_name, sum(ROUND((BYTEs/1048576*100)/100)) "MB size"
FROM dba_Segments a
WHERE a.owner= ??
and segment_type='TABLE'
group by segment_name
order by segment_name;
select table_name, degree
from dba_Tables
where owner='ADW_UTL'
and tablespace_name is not null
order by table_name;
how can i combined the two?
thanks in advance..Hi,
SELECT a.segment_name, sum(ROUND((BYTEs/1048576*100)/100)) "MB size", b.degree
FROM dba_Segments a, dba_tables b
WHERE a.owner= 'xxx'
and a.owner = b.owner
and segment_type='TABLE'
group by segment_name, degree
order by segment_name;
Cheers -
Query Scenario Help - Average of Multiple Regions
Hi, I have a query scenario I can't create and I hope someone can help with.
The user inputs a sales Area and the report is to output the regions in that area and provide the Volume (easy) and the Average of all the presented regions. The problem is that the number of regions is dynamic so I don't know how to go about determining the average and making it constant across the regions. The user can also drill down on a region to present divisions and I would then need the average for the divisions this time instead of regions. Can you help?
Example 1
Input Sales Area 1000000
Region 1000001 1000002 1000003
Product1 Volume 100 120 105
Product1 Average 108 108 108
Product2 Volume 200 400 325
Product2 Average 308 308 308
Example 2
Input Sales Area 2000000
Region 2000001 2000002 2000003 2000004
Product1 Volume 100 120 105 180
Product1 Average 126 126 126 126
Product2 Volume 200 400 325 600
Product2 Average 381 381 381 381
To get this layout I have the following in the query builder:
The 2 Products are in a structue under Rows
The Key figures structure is also under Rows
The Region is under the columnsIf you redesign the report slightly to move the "Average" to a column at the end of each row (which really makes more sense, IMHO), then the answer is easy. Just change the Suppress Results Row property to "Never" for Region, and change the Display Results As property to "Average" for Volume.
You could also make this same change to Division and/or any other free characteristic they might use as a drill-across in the report.
Hope this helps...
Bob -
Query HINT help requested Pls.
A query thus:
SELECT equipment_id,
vsemml.stock_equipment_id,
game_ware_id
FROM v_stocked_equipment_inven_his vsdeih,
v_stock_equipment_mod_man_list vsemml
WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
AND equipment_status_code IN
('ALL', 'AVA' )
AND ec_end_date IS NULL
AND eav_end_date IS NULL
GROUP BY equipment_id,
vsemml.stock_equipment_id,
game_ware_id
HAVING COUNT (model_attribute_value_id) =
(SELECT COUNT (*)
FROM stock_equipment JOIN stock_equipment_attrib_value
USING (stock_equipment_id)
WHERE stock_equipment_id =
vsemml.stock_equipment_id);
has result :
513 rows selected.
Elapsed: 00:04:59.17
Execution Plan
Plan hash value: 3816309895
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 240 | 21120 | | 38010 (7)| 00:07:37 |
|* 1 | FILTER | | | | | | |
| 2 | HASH GROUP BY | | 240 | 21120 | | 38010 (7)| 00:07:37 |
|* 3 | FILTER | | | | | | |
|* 4 | HASH JOIN OUTER | | 23915 | 2055K| | 38006 (7)| 00:07:37 |
|* 5 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
| 6 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
| 7 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
| 8 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 23915 | 1704K| | 37998 (7)| 00:07:36 |
| 9 | HASH UNIQUE | | 23915 | 2989K| 6392K| 37998 (7)| 00:07:36 |
|* 10 | HASH JOIN RIGHT OUTER | | 23915 | 2989K| | 37307 (7)| 00:07:28 |
| 11 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
|* 12 | HASH JOIN RIGHT OUTER | | 23915 | 2849K| | 37303 (7)| 00:07:28 |
| 13 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
|* 14 | HASH JOIN | | 23915 | 2615K| | 37297 (7)| 00:07:28 |
| 15 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 16 | 128 | | 3 (0)| 00:00:01 |
|* 16 | HASH JOIN | | 23915 | 2428K| | 37293 (7)| 00:07:28 |
| 17 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
|* 18 | HASH JOIN | | 645K| 60M| | 37278 (7)| 00:07:28 |
| 19 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
|* 20 | HASH JOIN | | 5288K| 458M| 9M| 37180 (7)| 00:07:27 |
| 21 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 297K| 6672K| | 784 (3)| 00:00:10 |
|* 22 | HASH JOIN | | 7467K| 484M| 6328K| 5447 (5)| 00:01:06 |
| 23 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
|* 24 | HASH JOIN | | 380K| 22M| 4528K| 3235 (2)| 00:00:39 |
|* 25 | HASH JOIN | | 140K| 2876K| | 563 (2)| 00:00:07 |
| 26 | MERGE JOIN | | 281 | 3372 | | 6 (17)| 00:00:01 |
| 27 | TABLE ACCESS BY INDEX ROWID| SITE_TYPE | 4 | 20 | | 2 (0)| 00:00:01 |
| 28 | INDEX FULL SCAN | PK_SITE_TYPE | 4 | | | 1 (0)| 00:00:01 |
|* 29 | SORT JOIN | | 281 | 1967 | | 4 (25)| 00:00:01 |
| 30 | VIEW | index$_join$_016 | 281 | 1967 | | 3 (0)| 00:00:01 |
|* 31 | HASH JOIN | | | | | | |
| 32 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
| 33 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
| 34 | TABLE ACCESS FULL | LOCATION | 140K| 1232K| | 554 (2)| 00:00:07 |
| 35 | TABLE ACCESS FULL | EQUIPMENT_CONFIGURATION | 380K| 15M| | 1460 (2)| 00:00:18 |
| 36 | SORT AGGREGATE | | 1 | 6 | | | |
| 37 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
|* 38 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
|* 39 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
"STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
"STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
"STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
3 - filter(("EQUIPMENT_STATUS_CODE"='ALL' OR "EQUIPMENT_STATUS_CODE"='AVA') AND "EC_END_DATE" IS NULL AND "EAV_END_DATE"
IS NULL)
4 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID"(+))
5 - access("SE"."MODEL_ID"="M"."MODEL_ID")
10 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
12 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
14 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
16 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID" AND
"STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
18 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID")
20 - access("EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
"EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
22 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
24 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
25 - access("L"."SITE_ID"="S"."SITE_ID")
29 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
filter("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
31 - access(ROWID=ROWID)
38 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
39 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
Query altered to:
=================
SELECT equipment_id,
vsemml.stock_equipment_id,
game_ware_id
FROM v_stocked_equipment_inven_his vsdeih,
v_stock_equipment_mod_man_list vsemml
WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
AND equipment_status_code = 'ALL'
AND ec_end_date IS NULL
AND eav_end_date IS NULL
GROUP BY equipment_id,
vsemml.stock_equipment_id,
game_ware_id
HAVING COUNT (model_attribute_value_id) =
(SELECT COUNT (*)
FROM stock_equipment JOIN stock_equipment_attrib_value
USING (stock_equipment_id)
WHERE stock_equipment_id =
vsemml.stock_equipment_id)
union
SELECT equipment_id,
vsemml.stock_equipment_id,
game_ware_id
FROM v_stocked_equipment_inven_his vsdeih,
v_stock_equipment_mod_man_list vsemml
WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
AND equipment_status_code = 'AVA'
AND ec_end_date IS NULL
AND eav_end_date IS NULL
GROUP BY equipment_id,
vsemml.stock_equipment_id,
game_ware_id
HAVING COUNT (model_attribute_value_id) =
(SELECT COUNT (*)
FROM stock_equipment JOIN stock_equipment_attrib_value
USING (stock_equipment_id)
WHERE stock_equipment_id =
vsemml.stock_equipment_id);
Results in:
513 rows selected.
Elapsed: 00:00:07.40
Execution Plan
Plan hash value: 3317078232
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 176 | | 6431 (51)| 00:01:18 |
| 1 | SORT UNIQUE | | 2 | 176 | | 6431 (51)| 00:01:18 |
| 2 | UNION-ALL | | | | | | |
|* 3 | FILTER | | | | | | |
| 4 | HASH GROUP BY | | 1 | 88 | | 3216 (2)| 00:00:39 |
|* 5 | HASH JOIN | | 95 | 8360 | | 3214 (2)| 00:00:39 |
|* 6 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
| 7 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
| 8 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
| 9 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 95 | 6935 | | 3207 (2)| 00:00:39 |
| 10 | HASH UNIQUE | | 95 | 12160 | | 3207 (2)| 00:00:39 |
|* 11 | HASH JOIN RIGHT OUTER | | 95 | 12160 | | 3206 (2)| 00:00:39 |
| 12 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
|* 13 | HASH JOIN OUTER | | 95 | 11590 | | 3202 (2)| 00:00:39 |
|* 14 | HASH JOIN | | 95 | 10640 | | 3196 (2)| 00:00:39 |
| 15 | TABLE ACCESS FULL | SITE_TYPE | 4 | 20 | | 3 (0)| 00:00:01 |
|* 16 | HASH JOIN | | 95 | 10165 | | 3193 (2)| 00:00:39 |
| 17 | VIEW | index$_join$_021 | 281 | 1967 | | 3 (0)| 00:00:01 |
|* 18 | HASH JOIN | | | | | | |
| 19 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
| 20 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
| 21 | NESTED LOOPS | | 95 | 9500 | | 3189 (2)| 00:00:39 |
|* 22 | HASH JOIN | | 96 | 8736 | 4440K| 3093 (2)| 00:00:38 |
|* 23 | HASH JOIN | | 56789 | 3771K| | 1679 (2)| 00:00:21 |
|* 24 | HASH JOIN | | 2894 | 178K| | 1273 (1)| 00:00:16 |
| 25 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
|* 26 | HASH JOIN | | 2894 | 158K| | 1271 (1)| 00:00:16 |
| 27 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
|* 28 | TABLE ACCESS BY INDEX ROWID| EQUIPMENT_CONFIGURATION | 1279 | 53718 | | 1265 (1)| 00:00:16 |
| 29 | NESTED LOOPS | | 1860 | 93000 | | 1268 (1)| 00:00:16 |
|* 30 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 1 | 8 | | 3 (0)| 00:00:01 |
|* 31 | INDEX RANGE SCAN | XIF3EQUIPMENT_CONFIGURATION | 23796 | | | 48 (3)| 00:00:01 |
| 32 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
|* 33 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 242K| 5451K| | 785 (3)| 00:00:10 |
| 34 | TABLE ACCESS BY INDEX ROWID | LOCATION | 1 | 9 | | 1 (0)| 00:00:01 |
|* 35 | INDEX UNIQUE SCAN | PK_LOCATION | 1 | | | 0 (0)| 00:00:01 |
| 36 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
| 37 | SORT AGGREGATE | | 1 | 6 | | | |
| 38 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
|* 39 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
|* 40 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
|* 41 | FILTER | | | | | | |
| 42 | HASH GROUP BY | | 1 | 88 | | 3216 (2)| 00:00:39 |
|* 43 | HASH JOIN | | 95 | 8360 | | 3214 (2)| 00:00:39 |
|* 44 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
| 45 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
| 46 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
| 47 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 95 | 6935 | | 3207 (2)| 00:00:39 |
| 48 | HASH UNIQUE | | 95 | 12160 | | 3207 (2)| 00:00:39 |
|* 49 | HASH JOIN RIGHT OUTER | | 95 | 12160 | | 3206 (2)| 00:00:39 |
| 50 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
|* 51 | HASH JOIN OUTER | | 95 | 11590 | | 3202 (2)| 00:00:39 |
|* 52 | HASH JOIN | | 95 | 10640 | | 3196 (2)| 00:00:39 |
| 53 | TABLE ACCESS FULL | SITE_TYPE | 4 | 20 | | 3 (0)| 00:00:01 |
|* 54 | HASH JOIN | | 95 | 10165 | | 3193 (2)| 00:00:39 |
| 55 | VIEW | index$_join$_044 | 281 | 1967 | | 3 (0)| 00:00:01 |
|* 56 | HASH JOIN | | | | | | |
| 57 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
| 58 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
| 59 | NESTED LOOPS | | 95 | 9500 | | 3189 (2)| 00:00:39 |
|* 60 | HASH JOIN | | 96 | 8736 | 4440K| 3093 (2)| 00:00:38 |
|* 61 | HASH JOIN | | 56789 | 3771K| | 1679 (2)| 00:00:21 |
|* 62 | HASH JOIN | | 2894 | 178K| | 1273 (1)| 00:00:16 |
| 63 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
|* 64 | HASH JOIN | | 2894 | 158K| | 1271 (1)| 00:00:16 |
| 65 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
|* 66 | TABLE ACCESS BY INDEX ROWID| EQUIPMENT_CONFIGURATION | 1279 | 53718 | | 1265 (1)| 00:00:16 |
| 67 | NESTED LOOPS | | 1860 | 93000 | | 1268 (1)| 00:00:16 |
|* 68 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 1 | 8 | | 3 (0)| 00:00:01 |
|* 69 | INDEX RANGE SCAN | XIF3EQUIPMENT_CONFIGURATION | 23796 | | | 48 (3)| 00:00:01 |
| 70 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
|* 71 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 242K| 5451K| | 785 (3)| 00:00:10 |
| 72 | TABLE ACCESS BY INDEX ROWID | LOCATION | 1 | 9 | | 1 (0)| 00:00:01 |
|* 73 | INDEX UNIQUE SCAN | PK_LOCATION | 1 | | | 0 (0)| 00:00:01 |
| 74 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
| 75 | SORT AGGREGATE | | 1 | 6 | | | |
| 76 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
|* 77 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
|* 78 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
"STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
"STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
"STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
5 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID")
6 - access("SE"."MODEL_ID"="M"."MODEL_ID")
11 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
13 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
14 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
16 - access("L"."SITE_ID"="S"."SITE_ID")
18 - access(ROWID=ROWID)
22 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID" AND
"EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
"EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
23 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
24 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
26 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID")
28 - filter("EC"."END_DATE" IS NULL)
30 - filter("ES"."EQUIPMENT_STATUS_CODE"='ALL')
31 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
33 - filter("EAV"."END_DATE" IS NULL)
35 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
39 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
40 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
41 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
"STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
"STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
"STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
43 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID")
44 - access("SE"."MODEL_ID"="M"."MODEL_ID")
49 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
51 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
52 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
54 - access("L"."SITE_ID"="S"."SITE_ID")
56 - access(ROWID=ROWID)
60 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID" AND
"EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
"EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
61 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
62 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
64 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID")
66 - filter("EC"."END_DATE" IS NULL)
68 - filter("ES"."EQUIPMENT_STATUS_CODE"='AVA')
69 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
71 - filter("EAV"."END_DATE" IS NULL)
73 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
77 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
78 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
5 minutes reduced to 7 seconds.!!
THE QUESTION.
Which (and where) query hint do I use to get the FIRST query to use the execution plan "method" of the second -
IE: To still perform well when a IN-LIST is used instead of EQUALS.
Technical:
Oracle 10.2.0.2 EE on Solaris 8, 64 bit.
Please help.
Thank you.
Below is the code of the referenced views for clarity.
CREATE OR REPLACE FORCE VIEW etrak.v_stocked_equipment_inven_his (stock_equipment_id,
equipment_id,
model_id,
gameset_id,
gameset_is_active,
game_ware_id,
game_ware_is_active,
equipment_status_code,
ec_start_date,
ec_end_date,
eav_start_date,
eav_end_date,
model_attribute_value_id,
site_id,
is_store
AS
SELECT DISTINCT stock_equipment_id, equipment_id, model_id, gameset_id,
gameset_is_active, game_ware_id, game_ware_is_active,
equipment_status_code, ec_start_date, ec_end_date,
eav_start_date, eav_end_date, model_attribute_value_id,
site_id, is_store
FROM (SELECT stock_equipment_id, equipment_id, model_id,
gameset_id, gameset_is_active, game_ware_id,
game_ware_is_active, equipment_status_code,
ec_start_date, ec_end_date, eav_start_date,
eav_end_date, model_attribute_value_id, site_id,
is_store
FROM (SELECT DISTINCT equipment_id, model_id,
gameset_id, gameset_is_active,
game_ware_id, game_ware_is_active,
equipment_status_code,
model_attribute_value_id,
ec_start_date, ec_end_date,
eav_start_date, eav_end_date,
site_id, is_store
FROM (SELECT ec.equipment_id,
ec.model_id,
gs.gameset_id,
gs.active_flag
AS gameset_is_active,
gw.game_ware_id,
gw.active_flag
AS game_ware_is_active,
es.equipment_status_code,
ec.start_date
AS ec_start_date,
ec.end_date
AS ec_end_date,
l.site_id, st.is_store
FROM equipment_configuration ec,
equipment_status es,
LOCATION l,
site s,
site_type st,
gameset gs,
game_ware gw
WHERE ec.equipment_status_id =
es.equipment_status_id
AND ec.gameset_id = gs.gameset_id(+)
AND gs.game_ware_id = gw.game_ware_id(+)
AND ec.location_id =
l.location_id
AND l.site_id = s.site_id
AND s.site_type_id =
st.site_type_id)
JOIN
(SELECT ec.equipment_id,
model_attribute_value_id,
eav.start_date
AS eav_start_date,
eav.end_date
AS eav_end_date
FROM equipment_configuration ec,
equipment_attribute_value eav
WHERE ec.equipment_id =
eav.equipment_id)
USING (equipment_id)
WHERE ( eav_start_date >=
ec_start_date
AND ( ( eav_end_date IS NULL
AND ec_end_date >=
eav_start_date
OR ec_end_date IS NULL
OR eav_end_date <=
ec_end_date
OR ( ec_start_date >=
eav_start_date
AND ( ( ec_end_date IS NULL
AND eav_end_date >=
ec_start_date
OR eav_end_date IS NULL
OR ec_end_date <=
eav_end_date
JOIN
(SELECT stock_equipment_id, model_id,
model_attribute_value_id
FROM stock_equipment JOIN stock_equipment_attrib_value
USING (stock_equipment_id)
) USING (model_id,
model_attribute_value_id)
CREATE OR REPLACE FORCE VIEW etrak.v_stock_equipment_mod_man_list (stock_equipment_id,
stock_equipment_code,
model_id,
model_name,
model_type_id,
model_type_code,
model_type_name,
man_id,
man_name
AS
SELECT se.stock_equipment_id, se.stock_equipment_code, m.model_id,
m.model_name, mt.model_type_id, mt.model_type_code,
mt.model_type_name, ma.man_id, ma.man_name
FROM stock_equipment se, model m, model_type mt, manufacturer ma
WHERE se.model_id = m.model_id
AND m.model_type_id = mt.model_type_id
AND m.man_id = ma.man_id;What also makes it difficult to read is the lack of formatting tags ([code][/code] or [pre][/pre]) so that we can actually read the code and execution plans.
I'm not going to trawl through formatting all that myself just to try and see what the differences are between query 1 and query 2.
Also bear in mind that when query 2 ran, the data may have been cached and so there is less physical I/O required.
You don't really want to use any hints to cause re-use of execution plans from 1 query to a different query (like I said, I don't know how different they are). What you want to do is determine what poor SQL coding is making the first query slow and fix it. -
Discoverer Report - SQL Query to retrieve list of parameters
Hi
We have around 100 Discoverer reports and I'm trying to find the list of parameters used in each report.
Is there any SQL query that I can use to find the parameters used for each report
or
should I open the reports one by one to fetch the list of parameters used.
I checked the tables in EUL4_US schema but no luck.
- Amarnath.Kgive this a try for starters. It looks at the custom folders defined in the business area, which is where any LOV's defined for you parameters would be. As far as looking at the workbooks themselves, no, there is no way to do that in sql.
select
decode(eb.ba_created_by,'ORACLE_APPS','Seeded','Custom') Origin,
eb.ba_name business_area,
eo.OBJ_TYPE,
decode(eo.obj_type, 'SOBJ','From Database', 'CUO', 'Custom Query', 'COBJ', 'Complex Folder', eo.obj_type) obj_type_desc,
eo.OBJ_NAME folder,
eo.OBJ_DESCRIPTION folder_description,
decode(eo.sobj_ext_table, NULL, NULL, eo.obj_ext_owner || '.' || eo.sobj_ext_table) base_object,
decode(es.seg_obj_id, null, UPPER(trim(eo.obj_object_sql1)||trim(eo.obj_object_sql2)||trim(eo.obj_object_sql3))
, UPPER(trim(es.seg_chunk1) || trim(es.seg_chunk2) || trim(es.seg_chunk3) || trim(es.seg_chunk4))) SQL
from
eul4_us.EUL5_BAS eb,
eul4_us.EUL5_objs eo,
eul4_us.EUL5_BA_OBJ_LINKS ebol,
eul4_us.eul5_segments es
where
eb.BA_ID = ebol.BOL_BA_ID and
ebol.BOL_OBJ_ID = eo.OBJ_ID and
eo.obj_id = es.seg_obj_id (+) and
decode(eb.ba_created_by,'ORACLE_APPS','Seeded','Custom') = 'Custom'
order by
/*decode(eb.ba_created_by,'ORACLE_APPS','Seeded','Custom'), */eb.ba_name, ebol.BOL_SEQUENCE, es.seg_sequence -
Performance issue on query. Help needed.
This is mainly a performance issue. I hope someone can help me on this.
Basically I have four tables Master (150000 records), Child1 (100000+ records), Child2 (50 million records !), Child 3 (10000+ records)
(please pardon the aliases).
Now every record in master has more than one corresponding record in each of the child tables (one to many).
Also there may not be any record in any or all of the tables for a particular master record.
Now, I need to fetch the max of last_updated_date for every master record in each of the 3 child tables and then find the maximum of
the three last_active_dates obtained from the 3 tables.
eg: for Master ID 100, I need to query Child1 for all the records of Master ID 100 and get the max last_updated_date.
Same for the other 2 tables and then get the maximum of these three values.
(I also need to take care of cases where no record may be found in a child table for a Master ID)
Writing a procedure that uses cursors that fetches the value from each of the child table hits performance
badly. And thing is I need to find out the last_updated_date for every Master record (all 150000 of them). It'll probably take days to do this.
SELECT MAX (C1.LAST_UPDATED_DATE)
,MAX (C2.LAST_UPDATED_DATE)
,MAX (C3.LAST_UPDATED_DATE)
FROM CHILD1 C1
,CHILD2 C2
,CHILD3 C3
WHERE C1.MASTER_ID = 100
OR C2.MASTER_ID = 100
OR C3.MASTER_ID = 100
I tried the above but I got a temp tablespace error. I don't think the query is good enough at all.
(The OR clause is to take care of no records in any child table. If there's an AND, then the join and hence select will
fail even if there is no record in one child table but valid values in the other 2 tables).
Thanks a lot.
Edited by: user773489 on Dec 16, 2008 11:49 AMNot sure I understand the problem. The max you are getting from the above is already the greatest out of the three - that's why we do the UNION ALL.
Here's sample code without output, maybe this will clear it up:
with a as (
select 10 MASTER_ID, to_date('12/15/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
select 20 MASTER_ID, to_date('12/01/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
select 30 MASTER_ID, to_date('12/02/2008', 'MM/DD/YYYY') LAST_DTE from dual
b as (
select 10 MASTER_ID, to_date('12/14/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
select 20 MASTER_ID, to_date('12/02/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
select 40 MASTER_ID, to_date('11/15/2008', 'MM/DD/YYYY') LAST_DTE from dual
c as (
select 10 MASTER_ID, to_date('12/07/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
select 30 MASTER_ID, to_date('11/29/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
select 40 MASTER_ID, to_date('12/13/2008', 'MM/DD/YYYY') LAST_DTE from dual
select MASTER_ID, MAX(LAST_DTE)
FROM
(select MASTER_ID, LAST_DTE from a UNION ALL
select MASTER_ID, LAST_DTE from b UNION ALL
select MASTER_ID, LAST_DTE from c)
group by MASTER_ID;
MASTER_ID MAX(LAST_DTE)
30 02-DEC-08
40 13-DEC-08
20 02-DEC-08
10 15-DEC-08
4 rows selectedEdited by: tk-7381344 on Dec 16, 2008 12:38 PM -
Error in Query (Pls help)
Hi friends,
When i executed one of the queries, i get this error:
Abort System error in program <b>CL_RSDM_READ_MASTER_DATA and form_sidval_direct</b>
Diagnosis
This internal error is a targeted termination since the program has an incorrect status.
Procedure
Analyse the situation and inform SAP.
I have check all my infoobjects and master data...everything is in active but still i dont understand why i get this....
please suggest how to get rid of this error? its urgent
Regards
BalajiHi balaji,
This can be program error, need to apply support package or correction,
seems no oss found for form_sidval_direct .....
perhaps it's sid error, try to analyze and repair the infoprovider where the query created on, use transaction RSRV.
hope this helps.
assign points if useful
Regards,
Archna -
Order by problem in my query - plz help me out
Dear all,
I have a query like this,
Select Booking_No, Get_Bl_Number (Booking_No) Bl_No, Depot_Code
From Booking_Table
Where Booking_Mode = 'B'
Order By Depot_Code, Bl_No, Booking_No
i need the output like NULLs of Bl_No should come first..ie.,
DEPOT_CODE BL_NO BOOKING_NO
DEPOT01 BOOKING01
DEPOT01 BL01 BOOKING02
DEPOT03 BL04 BOOKING03
DEPOT04 BOOKING04
DEPOT05 BL05 BOOKING06
since am using the function to get the Bl_No, am not getting the NULLs first...kindly help me out
Thanx and Rgds,
M ThiyaguYou can use like this:
Order By
Depot_Code,
Bl_No nulls first ,
Booking_No -
PROBLEM WITH HIERARCHICAL QUERY - PLEASE HELP
I have got three tables :
CREATE TABLE FIRM
(FID INTEGER NOT NULL PRIMARY KEY,
FNAME VARCHAR(40),
FTYPE VARCHAR(3),
MASTERID INTEGER );
CREATE TABLE FACULTY
(FAID INTEGER NOT NULL PRIMARY KEY,
FANAME VARCHAR(40),
FATYPE VARCHAR(3),
MASTERID INTEGER );
CREATE TABLE EMPLOYEE
(EID INTEGER NOT NULL PRIMARY KEY,
ENAME VARCHAR(20),
ESURNAME VARCHAR(20),
EJOB VARCHAR(3),
MASTERID INTEGER );
This is a hierarchical tree(or is ment to be, I,m complete rookie ) . Firm can be the root or can be slave to another firm. Faculty can be slave to firm, or to another faculty. Employee can be slave to faculty or to another employee(e.g. boss). This connections are specified by MASTERIDs.
I need to write a procedure, which parameter would be node ID. It is meant to create a VIEW from this node as if it was a root (view of a subtree).
I tried CONNECT BY clause but it works only on one table at a time and I have here three tables.
I completely don,t know how to write it. Please help.create view hierarchy as
select id, master_id, name from table1
union all
select id, master_id, name from table2
union all
select id, master_id, name from table3
Then do your connect by query against hierarchy.
It will not work in 8i (connect by on views not allowed), so you will need to materialize the view.
Kirill -
How to make recursive query.Please help
Dear Experts:
I want to retrieve all employees located in a department in addition to all other employees located in the child's nodes of this department too.
Problem Details:
I have "Employees" table and "Departments" Table
The structure of Dept Table is:
ID primary key
parent_dept foreign key(id)
deptname varchar2
deptType varchar2
The Employee table structure is
ID primary key
dept_id foreign key(Department.id)
empName varchar2Sample data for departments
ID : 1
parent_dept : null
deptname: General Manager office
deptType : 'GM'
ID :=2
parent_dept : 1
deptname: Information tech.
deptType : 'DPT'
ID :=3
parent_dept : 2
deptname: Software Development
deptType : 'SECTION'Sample Data for employees
ID : 101
dept_id :1
empName King
ID : 102
dept_id :2
empName ALAN
ID : 103
dept_id :2
empName SAM
ID : 104
dept_id :3
empName JANEI want to create a query that accepts a parameter "p_department_id" and returns All employees on the following conditions
1- In case the parameter value is null , then retrieve All Employees "king - alan- sam-jane"
2- In Case the parameter value is 1 , then retrieve all the employees under department id =1 in addition to all the employees located under the children departments.
in this case it will be "king - alan- sam-jane"
3- In case parameter value is 2 , then return all the employees under department id =2 in addition to all the employees located under the children departments.
In this case it will be " alan- sam-jane"
4- In case parameter value is 3 , then return all the employees under department id =3 in addition to all the employees located under the children departments.
in this case it will be only "JANE"
In brief , If I pass any value to the parameter :p_department_id , I want to retrieve all employees located in this department in addition to other employees located in the child's nodes of this department id
I use oracle database 11g release 2
Please help me
Thanks
Edited by: ta**** on Apr 3, 2013 5:56 PM
Edited by: ta**** on Apr 3, 2013 5:58 PMSQL> variable p_department_id number
SQL> exec :p_department_id := null
PL/SQL procedure successfully completed.
SQL> with employees as (
2 select 101 id,1 dept_id,'King' empName from dual union all
3 select 102,2,'ALAN' from dual union all
4 select 103,2,'SAM' from dual union all
5 select 104,3,'JANE' from dual
6 ),
7 departments as (
8 select 1 id,null parent_dept,'General Manager office' deptname,'GM' deptType from dual union all
9 select 2,1,'Information tech.','DPT' from dual union all
10 select 3,2,'Software Development','SECTION' from dual
11 )
12 select *
13 from employees
14 where dept_id in (
15 select id
16 from departments
17 start with (
18 (
19 :p_department_id is null
20 and
21 parent_dept is null
22 )
23 or
24 id = :p_department_id
25 )
26 connect by parent_dept = prior id
27 )
28 /
ID DEPT_ID EMPN
101 1 King
102 2 ALAN
103 2 SAM
104 3 JANE
SQL> exec :p_department_id := 1
PL/SQL procedure successfully completed.
SQL> /
ID DEPT_ID EMPN
101 1 King
102 2 ALAN
103 2 SAM
104 3 JANE
SQL> exec :p_department_id := 2
PL/SQL procedure successfully completed.
SQL> /
ID DEPT_ID EMPN
102 2 ALAN
103 2 SAM
104 3 JANE
SQL> exec :p_department_id := 3
PL/SQL procedure successfully completed.
SQL> /
ID DEPT_ID EMPN
104 3 JANE
SQL> SY. -
Table1
QTE_ID SEQ_NO
1435177 2
1435177 5
1435177 7
1435177 8
1435177 12
1435177 14
Table2
QTE_ID SEQ_NO CMMT_CURR_AMT
1435177 1 98500
1435177 2 98500
1435177 3 0
1435177 4 98500
1435177 5 98500
1435177 7 98500
1435177 8 98500
1435177 11 59300
1435177 12 59300
1435177 14 59300
The result should be
QTE_ID SEQ_NO CMMT_CURR_AMT
1435177 2 0 (where 0 = cmmt_curr_amt of seq 2 - cmmt_curr_amt of seq 1 from table 2)
1435177 5 0 (where 0 = cmmt_curr_amt of seq 5 - cmmt_curr_amt of seq 4 from table 2)
1435177 7 0 (where 0 = cmmt_curr_amt of seq 7 - cmmt_curr_amt of seq 5 from table 2)
1435177 8 0 (where 0 = cmmt_curr_amt of seq 8 - cmmt_curr_amt of seq 7 from table 2)
1435177 12 0 (where 0 = cmmt_curr_amt of seq 12 - cmmt_curr_amt of seq 11 from table 2)
1435177 14 0 (where 0 = cmmt_curr_amt of seq 14 - cmmt_curr_amt of seq 12 from table 2)
I have to get the difference of cmmt_curr_amt from the table2 from seq 14 to seq 12 for seq14 in table 1.
Please help me in writing the query.
Thanks in advance.
SrinivasWITH table1 AS
(SELECT 1435177 qte_id, 2 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no
FROM dual
table2 AS
SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
FROM dual
SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
FROM
(SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
FROM table1 t1, table2 t2
WHERE t2.qte_id = t1.qte_id (+)
AND t2.seq_no = t1.seq_no(+)
ORDER BY 1,2
WHERE t1_seq_no IS NOT NULL
ORDER BY 1,2
QTE_ID T2_SEQ_NO DIFF
1435177 2 0
1435177 5 0
1435177 7 0
1435177 8 0
1435177 12 0
1435177 14 0
Maybe you are looking for
-
IPod nano got wiped, now it won't work on my iTunes
Hi, I went home for the holidays, got a new CD and attempted to put it on my iPod at my parent's house using their iTunes. After the attempt, my iPod got totally wiped, all the music is completely gone. So I restored it. Now that I am back home, when
-
Lose quality when export to internet
I created a slideshow in iPhoto vs iMovie to maintain the photo quality (or so I thought). I exported it large and uploaded it to YouTube. However I lost too much quality to be useful. I exported it to .mov to Large size then opened it in iMovie. How
-
Word 2010 PDF adds "##B" characters to styleref fields
When I convert a Word document containing the styleref field (to insert the current heading in the header), to Acrobat, it adds numbers and the letter "B" before the styleref. The headings appear as "13BExecutive Summary", "20BAccount Management", e
-
Where to buy a replacement battery?
I have a 17" MacBook Pro with the dreaded exploding battery. Apple is unwilling to replace the D E F E C T I V E part. Where can I get a GOOD replacement battery, preferable not from Apple? After 7 home apple computers (about one every two years - th
-
Oracle concurrent program paramters r12
Hello, i want to create custom report in oracle apps the requirement is : Requirement (1) Excel report to be automated from Oracle ERP system by a concurrent job on a 1st of each calendar month with date parameters of 15th to 31st of previous calenda