Problems performing an outer join
I added some criteria to the following sql statement to get the relationship.
ie ('Husband', 'Wife','Father','Mother','Step Mother','Step Father','Father in-law','Mother in-law')
The problem is that I also want to beable to display those that are not in this category. So I thought that I could do and outer join such as
and hcr.relationship_name(+) in ('Husband',
'Wife',
This does not work. Can anyone recommend how I can perform an outer join to get that information that does not meet the in statement?
thanks
select hac.case_id,hac.relation_to_hoh_id,hcr.RELATIONSHIP_NAME,
decode(ha.GENDER_ID,1,'(F)',2,'(M)',3,'(T)') || ' Adult ' ||
round((trunc(sYSdate) - ha.DATE_OF_BIRTH) / 365,0) info, 0 sort_by
from dpss_hts.hts_applicant ha,
dpss_hts.hts_applicant_case hac,
dpss_hts.certa_relationship hcr
where ha.applicant_id = hac.applicant_id
and round((trunc(sYSdate) - ha.DATE_OF_BIRTH) / 365,0) > 17
and hac.relation_to_hoh_id = hcr.RELATIONSHIP_ID
and hcr.relationship_name in ('Husband',
'Wife',
'Father',
'Mother',
'Step Mother',
'Step Father',
'Father in-law',
'Mother in-law')
If I understand correctly, you want to display the relationship_name only if it is one of those in the list. If it is not, then you want to display the rest of the data, but not the realtionship_name.
Two approaches spring to mind. You can use an in-line view to select only the relationship_names you are interested in, then outer join to that in-line view like:
SELECT hac.case_id, hac.relation_to_hoh_id, hcr.relationship_name,
DECODE(ha.gender_id, 1, '(F)', 2, '(M)', 3, '(T)')||' Adult '||
ROUND((TRUNC(sysdate) - ha.date_of_birth) / 365, 0) info, 0 sort_by
FROM dpss_hts.hts_applicant ha, dpss_hts.hts_applicant_case hac,
SELECT relationship_id, relationship_name
FROM dpss_hts.certa_relationship
WHERE hcr.relationship_name in ('Husband', 'Wife', 'Father', 'Mother',
'Step Mother', 'Step Father',
'Father in-law', 'Mother in-law') hcr
WHERE ha.applicant_id = hac.applicant_id and
ROUND((TRUNC(sysdate) - ha.date_of_birth) / 365, 0) > 17 and
hac.relation_to_hoh_id = hcr.relationship_id(+)Another alternative would be do leave the current join intact, lose the predicate on relationship_name and do the dciding in the SELECT list.
Something like:
SELECT hac.case_id, hac.relation_to_hoh_id,
CASE WHEN hcr.relationship_name IN ('Husband', 'Wife', 'Father',
'Mother', 'Step Mother',
'Step Father', 'Father in-law',
'Mother in-law') THEN hcr.relationship_name
ELSE NULL END relationship_name,
DECODE(ha.gender_id, 1, '(F)', 2, '(M)', 3, '(T)')||' Adult '||
ROUND((TRUNC(sysdate) - ha.date_of_birth) / 365, 0) info, 0 sort_by
FROM dpss_hts.hts_applicant ha, dpss_hts.hts_applicant_case hac,
dpss_hts.certa_relationship hcr
WHERE ha.applicant_id = hac.applicant_id and
ROUND((TRUNC(sysdate) - ha.date_of_birth) / 365, 0) > 17 and
hac.relation_to_hoh_id = hcr.relationship_idHTH
John
Similar Messages
-
Performance when OUTER JOINS are used
Hello Everyone,
I have read in asktom.com about the performance of an SQL query when OUTER JOINS are used. I am not able to find the same artical and would like any of you guys to clarify if the sql that I have written would be better or not.
1. I haven't used OUTER JOINS in an SQL query. The query used 3-4 tables.
In those 3-4 tables one table is transaction table (big one) and the other are tables like transaction_type.
2. The transactions tables thas the typ_code and the typ_desc is present in transaction_type. It is one(transaction_type) to many(transactions) relationship
3. And also as all the typ_code of transactions tables has definte value in transaction_types table, I thought of not usng OUTER JOINS.
Would you guys agree with me?I have read in asktom.com about the performance of an
SQL query when OUTER JOINS are used. I am not able to
find the same artical and would like any of you guys
to clarify if the sql that I have written would be
better or not.The first thing to consider using outer joins or not - is whether the required business functionality needs them or not? Performance should be only the second thing because getting invalid results VERY FAST doesn't make any sense :)
Gints Plivna
http://www.gplivna.eu -
Hello expert,
following statement is left outer join or right outer join? and comparing with statement " from PCM RIGHT OUTER JOIN R ON PCM.practice_state_code = R.practice_state_code ", whose performance is better? Appreciate very much.
PCM.practice_state_code (+) = R.practice_state_codeHi,
843178 wrote:
Hello expert,
following statement is left outer join or right outer join?
PCM.practice_state_code (+) = R.practice_state_codeNeither. It's the old outer join notation. Using that syntax, the order in which you put the tables in the FROM clause doesn't matter.
and comparing with statement " from PCM RIGHT OUTER JOIN R ON PCM.practice_state_code = R.practice_state_code ", whose performance is better? They're equal. -
Outer Join problems - "ORA-30563 outer join operator (+) not allowed in select-list"
Products: Discoverer 4.1.33.0.2
(Admin and User/Plus)
8i EE 8.1.7 (Discoverer server)
8i EE 8.1.5 ('source data' server)
Background assumptions: (1) If a column from an "outer-joined" table is compared to a constant, the outer join operator must be applied to that column in order for the outer join to work. (2) A 'Condition' specified in Discoverer User/Plus manifests as a comparison to a constant.
I created a join in Admin between two folders, selected 'outer join on detail' option. In User/Plus, created worksheet containing columns from the joined folders. When no Conditions are NOT specified, results seem ok. However, when Condition IS added, worksheet encounters "ORA-30563 outer join operator (+) not allowed in select-list" and returns blank sheet.
To workaround, created Custom folder with outer join in place. Didn't work either with Conditions specified. No error, but I think that because Discoverer did not 'outer join' the Condition column, the outer join was ignored.
Any insights, ideas, or workarounds are much appreciated.
-JimIf you build a query that uses an outer join then any items from the potentially deficient side of the join will have (+) appended to them everywhere in the sql. Up until 8.1.7 this was OK in the select list as it was just treated as noise and ignored - However this now fails with ORA-30563:
outer join operator (+) not allowed in select-list...
In 4.1.33.1.6 you get the error 'ORA-30563 outer join operator(+) not allowed in select list'.
In 4.1.36.1.10 the query runs OK.. Your work around I would guess would be to create a custom folder as you suggested. -
Problem with outer joins and the class indicator/discriminator
Hello,
I am having a problem defining a query in toplink (10.1.3.3).
In the workbench, I have created a parent and 2 child descriptors. The parent is "AbstractValue", the children are "DefaultValue", classified by the discriminator 'DEF', and "OverrideValue", classified by 'OVR', both located in the same table.
Another descriptor (containing a one-on-one mapping to both a "DefaultValue", and a "OverrideValue") needs to be queried for its 'value'.
The way the query should act is: If an override value (row) exists, this one applies for that object. If an override doesn't exist, return the default value.
The query then comes down to (as I have it now):
builder.getAllowingNull("OverrideValue").getAllowingNull("value").ifNull(builder.get("DefaultValue").get("value")).equal(builder.getParameter(VALUE_PARAM));
The problem is that toplink adds the distinction for the different kind of "values" in the where clause WITHOUT checking for null values e.g. it performs an outer join, but then still checks for the discriminator value thus
....t1.ovr_id = t2.id(+) AND t2.discriminator = 'OVR' AND ...
instead of
... LEFT JOIN values t2 ON (t1.ovr_id = t2.id AND t2.discriminator = 'OVR') ...
This leads to the behaviour that the query returns ONLY the objects that have override and default values.
An overview of the queries (simplified)
Toplink, at the moment, returns only results if both override and default values exists:
SELECT t1.id
t1.def_id,
t1.ovr_id
FROM values t2,
parameter t1,
values t0
WHERE nvl(t2.value, t0.value) = 15 AND
t1.ovr_id = t2.id(+) AND t2.discriminator = 'OVR' AND
t1.def_id = t0.id AND t0.discriminator = 'DEF'
Situation Wanted:
SELECT t1.id
t1.def_id,
t1.ovr_id
FROM parameter t1
LEFT JOIN values t2 ON (t1.ovr_id = t2.id AND t2.discriminator = 'OVR')
JOIN values t0 ON (t1.def_id = t0.id AND t0.discriminator = 'DEF')
WHERE nvl(t2.value, t0.value) = 15
Anyone know if there is some statement I am missing to allow an actual outer join on descriptors containing class indicators/discriminators? A possible rewrite?
Thanks in advance,
RudyThis is a bug in TopLink's outer join support for Oracle. Currently the outer join is put in the where clause, instead of the from clause, as we do on other platforms. You might be able to fix it by changing your OraclePlatform to return false for shouldPrintOuterJoinInWhereClause().
Please log this bug on EclipseLink, or through Oracle technial support.
There is a workaround using,
descriptor.getInhertiancePolicy().setAlwaysUseOuterJoinForClassType(true);
James : http://www.eclipselink.org -
Query Question: Combine outer join with max() statement
Hi Folks,
I have been banging my head on this for a while now and am asking from some advice.
I have a Project Completion Report that pulls information from a number of tables:
1) Program (PK: ID)
2) Project (PK: ID, FK: Program_ID constrained to Program.ID)
3) Project_Monthly (PK: ID, FK: Project_ID constrained to Project.ID)
4) Status_Report (PK: ID, FK: Project_ID constrained to Project.ID)
The Status_Report table has a Record_Date field and holds a BLOB with the status reports for all the projects. In the best of all possible worlds, every project would have a status report, but, obviously, some have no status reports.
I have been asked to extend the Project Completion Report. It currently shows:
1) Program Number (Program.Program_Number)
2) Program Name (Program.Program_Name)
3) Project (Project.Project_Name)
4) Projected Completion Date (Project_Monthly.Current_Date_Production)
We would like to add the latest status report. So I started with something that works in another report, which is to get the ID from the Status_Report table for the record that has the maximum date value in the Record_date that matches the Project in the current Program. But this other query is looking at one program at a time. The Project Completion Report is showing all programs with projects that complete within a certain time frame.
The requirement is to show all projects that will complete within a time frame and to display the ID of the most recent status report (I use javascript to turn this into a downloadable link). However, whenever I try something like:
AND Status_Report.Record_Date =
(select MAX(Status_Report.record_date) from Status_Report
where Status_Report.ID = Project.ID)I loose all projects that have no status reports associated with them.
How can I keep all the projects that fulfill the criteria of completing within a specified time frame and add the ID, if it exists, of the most recent status report?
I thank you for your time and assistance. Please let me know how I can clarify the problem more clearly.
Yours,
PetieI had thought I finally solved it. Alas, it wasn't yet to be.
I created a view with the following select statement:
select p.program_number, p.program_name,
pj.id as pj_id, pj.project_name, pjm.in_prod_current, pjm.record_date as pjm_record_date,
prs.id as prs_ID, prs.record_date as prs_record_date
from program p, project pj, project_monthly pjm,
project_status_report prs
where p.id = pj.program_id
and pj.id = pjm.project_id
and pj.id = prs.project_id (+);Then, I selected from the view and the project_status_report table, performed an outer join on those (filtered to only the current month's project records) and filtered by the maximum date for each project.
Here is the resulting query:
select pc.program_number, pc.pj_id, pc.project_name, pc.in_prod_current,
pc.pjm_record_date, pc.prs_id
from project_completion pc,
project_status_report prs
where trunc(pjm_record_date, 'mon') = trunc(sysdate,'mon')
and prs.id = pc.prs_id (+)
and pc.prs_record_date =
(select max(mprs.record_date)
from project_status_report mprs
where mprs.project_id = pc.pj_id)However, I am still not getting the projects for which there are no status reports.
Verflixt und zugenaeht!
It seems that I want to compare based upon the record_date of the status report, but get the ID back. Can I use DECODE for that? Can I get the MAX(prs.record_date), but return only the prs.ID? Because if I include the ID in the select statement, I get too many matches, but if I don't then I don't have the ID, which is needed.
Any suggestions?
Thanks, Petie
Message was edited by:
Petie -
The following code is an example of how to perform an outer join, in this case with ReportQuery (thanks Doug):
ExpressionBuilder eb = new ExpressionBuilder();
ReportQuery rq = new ReportQuery(Employee.class, eb);
rq.addAttribute("firstName");
rq.addAttribute("lastName");
rq.addAttribute("areaCode", eb.anyOfAllowingNone("phoneNumbers").get("areaCode"));
List<ReportQueryResult> results = (List<ReportQueryResult>) session.executeQuery(rq);My question is about the logic Toplink uses to generate the outer join statement with the "(+)" in the generated sql.
Does Toplink only generate the join statement if the same attribute is chosen in the select statement (in the above example "areaCode")?
Along the same line of questioning, does it matter which attribute was in the get() call? So, in the above example did it have to be areaCode, or could it have been any other attribute of phoneNumber, and it still would have performed the join?
In my case, because the selection attributes are built up dynamicly, should I add all attributes of my child class (my equivalent PhoneNumber class)?Thanks for your reply Doug.
One last question, hopefully.
I have a parent table with 2 child tables. When attempting an outer join with both, toplink does not attempt to outer join either. I understand why, sort of - as you get an error when attempting this in sqlplus with "(+)" syntax.
I understand that you can outer join > 1 other table to a parent with ansi sql syntax:
select dept.*,emp.*
from dept left outer join emp
on dept.deptno = emp.deptnoWill toplink allow > 1 child table outer join to a parent table? -
Need help further tuning view source for outer join
I have been working on tuning views for use in Discoverer for some time, and I have greatly improved upon what was there, but it is still not where I need it to be. There are 2 views the users join together in Discoverer - one for contract lines, and one for contract flexfields. Run as a 1 to 1 join on contract number, performance is great. However, as soon as I have an outer join on flexfields, the performance is awful. We are talking a difference of under a minute to hours and hours. I have to be able to perform an outer join because there can be contracts without flexfields. Can anyone suggest an alternative method to get the data or further tuning? I will paste both the contract lines and contract flexfields source - I have tuned the flexfields but have done nothing to date with the lines.
CREATE OR REPLACE VIEW XXDBD_CONTRACT_FLEXFIELDS AS
SELECT core.contract_id, core.service_id, core.contract_number, core.service_line, core.service, core.product_line, core.equipment, core.UL_Certificate_And_End_Date, core.MAF, core.Termination_Penalty_Percentage, core.multi_year, core.multi_year_effective_dates, core.terms_multi_year, core.SerLineRenPricingMethod, core.ren_line_change, core.zone, core.add_invoice_display, core.add_subgrouping, re.diebold_price, attr.coverage_hours, attr.reaction_times, attr.resolution_times, attr.repair_times, tr.performance_requirement, attr.penalty, attr.penalty_amount, attr.penalty_bonus, attr.mon_break_start, attr.mon_break_end, attr.tues_break_start, attr.tues_break_end, attr.wed_break_start, attr.wed_break_end, attr.thu_break_start, attr.thu_break_end, attr.fri_break_start, attr.fri_break_end, attr.sat_break_start, attr.sat_break_end, attr.sun_break_start, attr.sun_break_end, attr.split_covering, attr.cash_handling
FROM (SELECT aa.ID Contract_id,
aa.contract_number,
dd.id Service_ID ,
dd.cle_id dd_cle_id,
dd.line_number service_line,
xxdbd_Disco_Service_Contract.GetServNameInv
(dd.id) Service,
dd.line_number ||'.'||ee.line_number Product_Line,
xxdbd_Disco_Service_Contract.GetEqpNoInvoice(ee.id)
Equipment,
DECODE(dd.attribute_category,'Service Contracts',
NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_50_CHARS', dd.attribute1),dd.attribute1),'') UL_Certificate_And_End_Date,
dd.attribute2 MAF,
DECODE(dd.attribute_category,'Service Contracts',NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute3),dd.attribute3),'') Termination_Penalty_Percentage,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_MULTIYEAR', dd.attribute5),dd.attribute5),
'N','No Multi-Year',
'Y','Multi-Year, Years not Known',
'Y1','Multi-Year for 1 Year',
'Y2','Multi-Year for 2 Year',
'Y3','Multi-Year for 3 Year',
'Y4','Multi-Year for 4 Year',
'Y5','Multi-Year for 4 Year',dd.attribute5),'')Multi_Year,
dd.attribute4 Multi_Year_Effective_Dates,
DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_450_CHARS', dd.attribute9),dd.attribute9),'') Terms_Multi_Year,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_RENEWAL_PRICING', dd.attribute6),dd.attribute6),
'MP', 'DBD Markup Percent',
'CP', 'DBD Contract Price',
'AI', 'DBD Amount Increase',
'AD', 'DBD Amount Decrease',
'TA', 'DBD Target Amount',
'FR', 'DBD Flat Rate',dd.attribute6),'') SerLineRenPricingMethod,
DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute7),dd.attribute7),'') Ren_Line_Change,
DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_ZONE', dd.attribute8),dd.attribute8),
'DNA1','DNA Zone 1',
'DNA2','DNA Zone 2',
'DNA3','DNA Zone 3',
'BRAZIL1','Brazil Zone 1 (50 KM)',
'BRAZIL2','Brazil Zone 2 (80 KM)',
'BRAZIL3','Brazil Zone 3 (200 KM)',dd.attribute8),'')Zone,
DECODE(dd.attribute11, 'N','None','SC','Sub Component', 'SN', 'Serial Number', 'SNSC', 'Serial Number and Sub-Component') Add_Invoice_Display,
DECODE(dd.attribute10, 'SI','Service Item', 'CP','Covered Product', 'PC','Product Category') Add_SubGrouping,
dd.attribute12 Diebold_Price,
ee.id ee_id,
ee.cle_id ee_cle_id
FROM okc_k_headers_b aa,
okc_k_lines_b dd,
okc_k_lines_b ee
-- xxdbd_temp_flex_contract tfc
WHERE aa.id = dd.DNZ_CHR_ID
AND dd.CLE_ID IS NULL
AND dd.id = ee.cle_id
AND ee.DNZ_CHR_ID = aa.id
AND ee.LSE_ID =9
AND dd.LSE_ID =1
-- and aa.contract_number = 'NL0000014'
-- and aa.contract_number in (select contract_number from xxdbd_flex_contract)
-- AND tfc.contract_number = aa.contract_number
) core,
(SELECT h.contract_number,
DECODE(l.attribute_category,
'Coverage Break', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),
'Business Process',xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,1)),
'Coverage Template Header',xxdbd_get_sib_cont_id(l.cle_id),
'Transaction Type', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),null) ee_id,
DECODE(l.attribute_category, 'Business Process', l.attribute1) Coverage_Hours,
DECODE(l.attribute_category, 'Business Process', l.attribute2) Reaction_Times,
DECODE(l.attribute_category, 'Business Process', l.attribute3) Resolution_Times,
DECODE(l.attribute_category, 'Business Process', l.attribute4) Repair_Times,
DECODE(l.attribute_category, 'Business Process', DECODE(l.attribute5,
'RA', 'REACTION'
, 'RS', 'RESOLUTION'
, 'RR', 'REACTION & RESOLUTION'
, 'NR', 'NO REQUIREMENT',
l.attribute5)) Performance_Requirement,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute1) Penalty,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute2) Penalty_Amount,
DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute2) Mon_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute3) Tues_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute4) Tues_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute5) Wed_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute6) Wed_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute7) Thu_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute8) Thu_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute9) Fri_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute10) Fri_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute11) Sat_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute12) Sat_Break_End,
DECODE(l.attribute_category, 'Coverage Break', l.attribute13) Sun_Break_Start,
DECODE(l.attribute_category, 'Coverage Break', l.attribute14) Sun_Break_End,
DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,
DECODE(l.attribute_category, 'Transaction Type', l.attribute2) Cash_Handling
from okc_k_lines_b l , okc_k_headers_b h--, xxdbd_temp_flex_contract tfc
where l.attribute_category in ('Coverage Break', 'Business Process', 'Coverage Template Header','Transaction Type')
and h.id = l.dnz_chr_id
-- and h.contract_number in (select contract_number from xxdbd_flex_contract)
-- and tfc.contract_number = h.contract_number
) attr
where core.ee_id = attr.ee_id (+)
and core.contract_number = attr.contract_number (+);
create or replace view xxdbd_contract_lines as
select aa.id Contract_id,
bb.id Service_id,
aa.CONTRACT_NUMBER,
F1.USER_NAME Created_By,
F2.USER_NAME LastUpdated_By,
bb.LINE_NUMBER Service_Line_No,
bb.LINE_NUMBER ||'.'|| cc.LINE_NUMBER Product_Line_No,
xxdbd_Disco_Service_Contract.GetServNameInv(bb.id) Service,
xxdbd_Disco_Service_Contract.GetServDescInv(bb.id) Service_Desc,
xxdbd_Disco_Service_Contract.GetServicePrice(bb.id) Service_Price,
bb.PRICE_UNIT Service_List_Price,
bb.CURRENCY_CODE,
aa.SCS_CODE Contract_Type,
bb.STS_CODE Service_Status,
bb.TRN_CODE Term_Code,
bb.START_DATE Service_start,
bb.END_DATE Service_end,
TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' )) SERVICE_BillToSite,
xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' ))) Bill_Account,
xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_BILLTO' ))) Service_BillTo,
TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' )) SERVICE_ShipToSite ,
xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Service_Ship_To,
xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Ship_Account,
bb.DATE_RENEWED,
bb.DATE_TERMINATED,
cc.START_DATE Eqp_Start,
cc.END_DATE Eqp_End,
xxdbd_Disco_Service_Contract.GetEqpNoInvoice(cc.id) Eqp_No,
xxdbd_Disco_Service_Contract.GetEqpDescInvoice(cc.ID) Eqp_Desc,
xxdbd_Disco_Service_Contract.GetEqpQuantityInvoice(cc.id) Eqp_Quan,
xxdbd_Disco_Service_Contract.GetEqpSerialNoInvoice(cc.id) Eqp_Serial,
xxdbd_Disco_Service_Contract.GetCustomerCt(aa.id, bb.id) Cust_Contact,
DD.ORGANIZATION_ID,
dd.INSTALL_ADDRESS,
dd.INSTALL_DATE,
dd.INSTALL_SITE_ID INSTALL_SITE_USE_ID,
dd.PARTY_SITE_NAME INSTALL_SITE_NAME,
dd.PARTY_SITE_NUMBER INSTALL_SITE_NUMBER
,cii.inventory_item_id
,cii.inv_master_organization_id
,aa.authoring_org_id
,cc.id equipment_id
,TO_NUMBER(replace(bb.attribute12,',','')) annual_contract_amt
,ou.name operating_unit
,ou.organization_id operating_unit_id
,substr(xxdbd_ra_utility.Get_BusinessProcess(cc.cle_id),1,100) business_process
,cii.instance_id
,cii.instance_number
from okc_k_headers_b aa
,okc_k_lines_b bb
,okc_k_lines_b cc
,fnd_user f1
,fnd_user f2
,csi_item_instances cii
,okc_k_items items
,hr_all_organization_units ou
,xxdbd_oks_install_info_v dd
where aa.id = bb.dnz_chr_id
and bb.cle_id is null
and cc.cle_id = bb.id
and cc.dnz_chr_id = aa.id
and f1.user_id = bb.created_by
and f2.user_id = bb.last_updated_by
and cc.lse_id in (9,25,18,40)
and dd.line_id (+) = cc.id
and items.cle_id = cc.id
and cii.instance_id = items.object1_id1
and aa.authoring_org_id = ou.organization_id (+);
Here are the explain plans from TOAD:
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 6 49124
NESTED LOOPS OUTER 6 80 K 49124
VIEW 6 80 K 49112
HASH JOIN 6 1 K 49112
HASH JOIN 17 K 2 M 20214
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
VIEW PUSHED PREDICATE 1 107 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
NESTED LOOPS 50 5 K 219
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 245 63309
NESTED LOOPS 245 291 K 63309
NESTED LOOPS OUTER 245 286 K 63064
NESTED LOOPS 245 80 K 62574
HASH JOIN 245 74 K 61839
HASH JOIN 245 71 K 61756
HASH JOIN OUTER 245 68 K 61673
HASH JOIN 245 60 K 61664
HASH JOIN 205 K 32 M 28046
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 244 K 37
TABLE ACCESS FULL OKC.OKC_K_LINES_B 205 K 23 M 27803
TABLE ACCESS FULL OKC.OKC_K_LINES_B 2 M 168 M 27803
TABLE ACCESS FULL HR.HR_ALL_ORGANIZATION_UNITS 2 K 64 K 8
TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
UNION-ALL PARTITION
NESTED LOOPS 1 167 9
NESTED LOOPS 1 108 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 144 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 161 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
And here is the SQL to join:
select * from xxdbd_contract_lines l, xxdbd_contract_flexfields f
where f.service_id (+) = l.service_id
and f.contract_number (+) = l.contract_number
and l.contract_number = 'NL0000014'
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 1 49221
HASH JOIN OUTER 1 38 K 49221
VIEW APPS.XXDBD_CONTRACT_LINES 1 19 K 96
NESTED LOOPS OUTER 1 1 K 96
NESTED LOOPS 1 358 94
NESTED LOOPS 1 345 93
NESTED LOOPS 1 332 92
NESTED LOOPS 1 311 91
NESTED LOOPS 1 285 88
NESTED LOOPS 448 72 K 88
NESTED LOOPS OUTER 1 78 4
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 46 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
TABLE ACCESS BY INDEX ROWID HR.HR_ALL_ORGANIZATION_UNITS 1 32 1
INDEX UNIQUE SCAN HR.HR_ORGANIZATION_UNITS_PK 1
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 378 32 K 84
INDEX RANGE SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 378 16
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 119
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
UNION-ALL PARTITION
NESTED LOOPS 1 167 9
NESTED LOOPS 1 108 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 144 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
NESTED LOOPS 1 161 8
NESTED LOOPS 1 85 7
NESTED LOOPS 1 51 6
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
VIEW APPS.XXDBD_CONTRACT_FLEXFIELDS 6 112 K 49124
NESTED LOOPS OUTER 6 80 K 49124
VIEW 6 80 K 49112
HASH JOIN 6 1 K 49112
HASH JOIN 17 K 2 M 20214
TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
VIEW PUSHED PREDICATE 1 107 2
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
NESTED LOOPS 50 5 K 219
TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,Uh oh, the dreaded entity attibute value, or generic, data model.
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:10678084117056
I am afraid slow performance is a built in feature of this database design, not much you can do in queries.
You could possibly create the views as materialized views and query those instead.
Quote from the linked article
But, how does it perform? Miserably, terribly, horribly. A simple "select
first_name, last_name from person" query is transformed into a 3-table join with
aggregates and all. Further, if the attributes are "NULLABLE" - that is, there
might not be a row in OBJECT_ATTRIBUTES for some attributes, you may have to
outer join instead of just joining which in some cases can remove more optimal
query plans from consideration.
Writing queries might look pretty straightforward, but it's impossible to do in
a performant fashion. -
Hi Experts,
I am facing a problem with left outer join query. Am using one standard table and ztable for this join. My problem is values are not extracted from the Ztable.
Query:
SELECT b~lifnr b~belnr b~gjahr b~xblnr b~shkzg b~blart b~zfbdt b~budat b~wrbtr
b~wskto b~zlspr s~EXTRACT_STATUS s~maturity_date FROM bsik AS b
LEFT OUTER JOIN zprm_rvne_sapdoc AS s
ON s~belnr EQ b~belnr
AND s~gjahr EQ b~gjahr
INTO CORRESPONDING FIELDS OF TABLE it_join
WHERE b~zlsch = p_zlsch
AND b~xblnr IN so_invno
ORDER BY b~lifnr b~xblnr.
I have all entries of BSIK table in Ztable with extract status as Y but this query is not fetching extract status and maturity date of ztable so it is blank in the internal table.
Need solution.
Regards
Sridevi SHi,
see the sample wiki for writing the Left outer join
http://wiki.sdn.sap.com/wiki/display/Snippets/EmployeeInfotype0000to9999ChangeHistory
Specifying Two or More Database Tables as a Left Outer Join
The left outer join, on the other hand, reads lines from the left-hand database table or join even if there is no corresponding line in the right-hand table.
SELECT...
FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS <alias>] ON <cond>
<options>
<tab> and <dbtab> are subject to the same rules and conditions as in an inner join. The OUTER addition is optional. The tables are linked in the same way as the inner join with the one exception that all lines selected from <tab> are included in the final selection. If <dbtab> does not contain any lines that meet the condition <cond>, the system includes a single line in the selection whose columns from <dbtab> are filled with null values.
In the left outer join, more restrictions apply to the condition <cond> than in the inner join. In addition to the above restrictions:
EQ or = is the only permitted relational operator.
There must be at least one comparison between columns from <tab> and <dbtab>.
The WHERE clause may not contain any comparisons with columns from <dbtab>. All comparisons using columns from <dbtab> must appear in the condition <cond>.
If we have two tables named stud1,stud2 with the following data
Stud1: id Name stud2: id Name
1 xxx 1 aaa
2 yyy 2 bbb
3 zzz 4 ccc
4 www 6 ddd
When we use Left Outer Join we get the output as:
1 aaa
2 bbb
3 <Null>
4 ccc
When we use Right Outer Join we get the output as:
1 aaa
2 bbb
4 ccc
<Null> ddd
When we use Full Outer Join we get the output as:
1 aaa
2 bbb
3 <Null>
4 ccc
<Null> ddd
Prabhudas -
How to use left outer join on more than one table (source)
Hi all,
In our project we are converting the Unix shell & SQL scripts into OWB mappings. We are facing problem converting left outer join in OWB. here is one of the example. i have just pasted the FROM and where condition.
FROM ym_scr t1, branch_finmonth t3
LEFT OUTER JOIN item_image t2
ON (t1.branch_no = t2.branch_no
AND t1.item_no = t2.item_no
AND t3.to_date between t2.tran_dt and t2.to_dt
AND t2.to_dt >= '$start_images' ) <<<========= '$start_images' THIS COMES FROM THE UNIX VARAIBLE ,
We converts the same when we are putting it in OWB join Operator
INGRP1.branch_no = INGRP2.branch_no(+)
AND INGRP1.item_no = INGRP2.item_no(+)
AND INGRP3.to_date between t2.tran_dt and t2.to_dt
AND INGRP2.to_dt >= INGRP2.start_images
But as you see in the OWB opreator we can put left join with INGRP1 with INGRP2.
We can not make same join with INGRP3 & INGRP4 , becoz it failed saying "you cannot left outer join on more than one table/source".
so overall this OWB code makes incomplete left outer join as per the above ANSI SQL join in Oracle.
Bcoz of the problem we are getting less number of rows...........
SO please please help me on this
Regards
AshokHi.
I know this topic is here for a while now, but I had the same problem today, searched for help and didn´t find anything.
Later I figured out how to do this.
You just have to put the (+) one time, and the OWB converts in an LEFT OUTER JOIN statement.
For this case, all you have to do is:
( INGRP1.branch_no = INGRP2.branch_no(+) AND INGRP1.item_no = INGRP2.item_no AND INGRP2.to_dt >= INGRP2.start_images )
Regards,
Godoy -
Problem with outer join with filter on join column
Hi,
In physical layer I have one dimension and two facts, and there's an outer join between the facts.
dim_DATE ,
fact_1 ,
fact_2
Joins:
dim_DATE inner join fact_1 on dim_DATE.DATE = fact_1.DATE
fact_1 left outer join fact_2 on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
When I run a report with a date as a filter, OBIEE executes "optimized" physical SQL:
select fact1.X, fact2.Y
from
Fact_1 left outer join on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
where Fact_1.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD' )
and Fact_2.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD')
The filter on Fact_2.DATE effectively replaces outer join with inner.
Is there a way to disable this "optimization", which is actually very good for inner joins, but doesn't allow outer joins?
Thanks in advance,
Alex
Edited by: AM_1 on Aug 11, 2009 8:20 AMIf you want to perform a Fact-based partitioning with OBIEE (two fact with the same dimension), you have to :
* create in your physical layer for each fact table the joins with the dimension
* create in the Business Model layer ONE star schema with ONE logical fact table containing the columns of your two physical fact table
In this way when you choose minimal one column of your fact1 and one column of your fact2, OBIEE will perform two query against each fact table/dimension, join them with an OUTER JOIN and your problem will disappear.
Cheers
Nico -
Performance difference between left outer join / inner join
Hi,
I've got a complex query which among other things accesses quite a large table. If I use inner join to join this table, the response is quite fast and execution plan shows it uses nested loops to gather the data.
If I change inner join to left outer join, I get a big performance drop. Cost of query goes from 1441 to 28544.
I don't uderstand why there's such a difference. For inner join, database has to remove all the rows that don't have match in inner-joined table. For left join it can keep all records and just return NULL values for records that don't have a match. In my mind left join should be faster, as it seems simpler. And the access plan could be the same, couldn't it?
Execution plan for inner join:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 288 | 1441 (1)| 00:00:18 |
| 1 | HASH GROUP BY | | 1 | 288 | 1441 (1)| 00:00:18 |
| 2 | NESTED LOOPS OUTER | | 1 | 288 | 1440 (1)| 00:00:18 |
| 3 | NESTED LOOPS | | 1 | 261 | 1438 (1)| 00:00:18 |
| 4 | NESTED LOOPS | | 318 | 74412 | 508 (1)| 00:00:07 |
| 5 | NESTED LOOPS | | 318 | 51834 | 189 (0)| 00:00:03 |
| 6 | TABLE ACCESS BY INDEX ROWID| RESURCE | 1 | 106 | 1 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | RESURCE_PRINCIPAL_NAME_INDEX | 1 | | 0 (0)| 00:00:01 |
| 8 | TABLE ACCESS BY INDEX ROWID| TASK_USES_RESURCE | 318 | 18126 | 188 (0)| 00:00:03 |
|* 9 | INDEX RANGE SCAN | TASK_USES_RESUR_IDX$$_0CDC0002 | 318 | | 3 (0)| 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID | TASK | 1 | 71 | 1 (0)| 00:00:01 |
|* 11 | INDEX UNIQUE SCAN | TASK_PK | 1 | | 0 (0)| 00:00:01 |
| 12 | TABLE ACCESS BY INDEX ROWID | TASK_WORK_HISTORY | 1 | 27 | 3 (0)| 00:00:01 |
|* 13 | INDEX RANGE SCAN | TASK_WORK_HISTORY_INDEX1 | 1 | | 2 (0)| 00:00:01 |
| 14 | TABLE ACCESS BY INDEX ROWID | TASK_USES_RESURCE | 1 | 27 | 2 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | TASK_USES_RESURCE_UK1 | 1 | | 1 (0)| 00:00:01 |
For left outer join:
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 318 | 1596K| | 28544 (2)| 00:05:43 |
|* 1 | HASH JOIN OUTER | | 318 | 1596K| 1584K| 28544 (2)| 00:05:43 |
| 2 | VIEW | | 318 | 1580K| | 508 (1)| 00:00:07 |
| 3 | NESTED LOOPS | | 318 | 74412 | | 508 (1)| 00:00:07 |
| 4 | NESTED LOOPS | | 318 | 51834 | | 189 (0)| 00:00:03 |
| 5 | TABLE ACCESS BY INDEX ROWID| RESURCE | 1 | 106 | | 1 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | RESURCE_PRINCIPAL_NAME_INDEX | 1 | | | 0 (0)| 00:00:01 |
| 7 | TABLE ACCESS BY INDEX ROWID| TASK_USES_RESURCE | 318 | 18126 | | 188 (0)| 00:00:03 |
|* 8 | INDEX RANGE SCAN | TASK_USES_RESUR_IDX$$_0CDC0002 | 318 | | | 3 (0)| 00:00:01 |
| 9 | TABLE ACCESS BY INDEX ROWID | TASK | 1 | 71 | | 1 (0)| 00:00:01 |
|* 10 | INDEX UNIQUE SCAN | TASK_PK | 1 | | | 0 (0)| 00:00:01 |
| 11 | VIEW | | 1480K| 73M| | 23431 (2)| 00:04:42 |
|* 12 | HASH JOIN RIGHT OUTER | | 1480K| 76M| 38M| 23431 (2)| 00:04:42 |
| 13 | TABLE ACCESS FULL | TASK_USES_RESURCE | 1486K| 21M| | 2938 (2)| 00:00:36 |
| 14 | VIEW | | 1445K| 53M| | 15031 (2)| 00:03:01 |
| 15 | HASH GROUP BY | | 1445K| 37M| 110M| 15031 (2)| 00:03:01 |
| 16 | TABLE ACCESS FULL | TASK_WORK_HISTORY | 1445K| 37M| | 3897 (2)| 00:00:47 |
--------------------------------------------------------------------------------------------------------------------------...continued
Complete execution plan for left join:
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 318 | 1594K| | 28544 (2)| 00:05:43 |
|* 1 | HASH JOIN OUTER | | 318 | 1594K| 1584K| 28544 (2)| 00:05:43 |
| 2 | VIEW | | 318 | 1578K| | 508 (1)| 00:00:07 |
| 3 | NESTED LOOPS | | 318 | 74412 | | 508 (1)| 00:00:07 |
| 4 | NESTED LOOPS | | 318 | 51834 | | 189 (0)| 00:00:03 |
| 5 | TABLE ACCESS BY INDEX ROWID| RESURCE | 1 | 106 | | 1 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | RESURCE_PRINCIPAL_NAME_INDEX | 1 | | | 0 (0)| 00:00:01 |
| 7 | TABLE ACCESS BY INDEX ROWID| TASK_USES_RESURCE | 318 | 18126 | | 188 (0)| 00:00:03 |
|* 8 | INDEX RANGE SCAN | TASK_USES_RESUR_IDX$$_0CDC0002 | 318 | | | 3 (0)| 00:00:01 |
| 9 | TABLE ACCESS BY INDEX ROWID | TASK | 1 | 71 | | 1 (0)| 00:00:01 |
|* 10 | INDEX UNIQUE SCAN | TASK_PK | 1 | | | 0 (0)| 00:00:01 |
| 11 | VIEW | | 1480K| 73M| | 23431 (2)| 00:04:42 |
|* 12 | HASH JOIN RIGHT OUTER | | 1480K| 76M| 38M| 23431 (2)| 00:04:42 |
| 13 | TABLE ACCESS FULL | TASK_USES_RESURCE | 1486K| 21M| | 2938 (2)| 00:00:36 |
| 14 | VIEW | | 1445K| 53M| | 15031 (2)| 00:03:01 |
| 15 | HASH GROUP BY | | 1445K| 37M| 110M| 15031 (2)| 00:03:01 |
| 16 | TABLE ACCESS FULL | TASK_WORK_HISTORY | 1445K| 37M| | 3897 (2)| 00:00:47 |
Query Block Name / Object Alias (identified by operation id):
1 - SEL$1AFB0324
2 - SEL$58A6D7F6 / from$_subquery$_005@SEL$8
3 - SEL$58A6D7F6
5 - SEL$58A6D7F6 / RESURCEWORKER@SEL$2
6 - SEL$58A6D7F6 / RESURCEWORKER@SEL$2
7 - SEL$58A6D7F6 / TASKUSESRESURCE@SEL$1
8 - SEL$58A6D7F6 / TASKUSESRESURCE@SEL$1
9 - SEL$58A6D7F6 / TASK@SEL$1
10 - SEL$58A6D7F6 / TASK@SEL$1
11 - SEL$7EBCC247 / TRW@SEL$3
12 - SEL$7EBCC247
13 - SEL$7EBCC247 / TUR@SEL$4
14 - SEL$6 / TRW_IN@SEL$5
15 - SEL$6
16 - SEL$6 / TWH@SEL$6
Predicate Information (identified by operation id):
1 - access("TRW"."RESURCE_ID"(+)="TASKUSESRESURCE"."RESURCE_ID" AND "TRW"."TASK_ID"(+)="TASK"."ID")
6 - access("RESURCEWORKER"."USER_PRINCIPAL_NAME"=U'jernej')
8 - access("TASKUSESRESURCE"."RESURCE_ID"="RESURCEWORKER"."ID")
10 - access("TASKUSESRESURCE"."TASK_ID"="TASK"."ID")
12 - access("TUR"."RESURCE_ID"(+)="TRW_IN"."RESURCE_ID" AND "TUR"."TASK_ID"(+)="TRW_IN"."TASK_ID") Jonathan, I've been to one of your workshops in Ljubljana. I'm still trying to understand everything you explained and use it, but there's much I have to learn and understand.
The way I see this query it should fist join and filter the first three tables and only then join the trw subquery. The problem with this subqrey is task_work_history table, which is accessed in very different ways in different places, so there will always be many reads to gather required data. For now, however, I'd be hapy to just bring the performance of inner join to left join... -
Problem with XMLTABLE and LEFT OUTER JOIN
Hi all.
I have one problem with XMLTABLE and LEFT OUTER JOIN, in 11g it returns correct result but in 10g it doesn't, it is trated as INNER JOIN.
SELECT * FROM v$version;
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
--test for 11g
CREATE TABLE XML_TEST(
ID NUMBER(2,0),
XML XMLTYPE
INSERT INTO XML_TEST
VALUES
1,
XMLTYPE
<msg>
<data>
<fields>
<id>g1</id>
<dat>data1</dat>
</fields>
</data>
</msg>
INSERT INTO XML_TEST
VALUES
2,
XMLTYPE
<msg>
<data>
<fields>
<id>g2</id>
<dat>data2</dat>
</fields>
</data>
</msg>
INSERT INTO XML_TEST
VALUES
3,
XMLTYPE
<msg>
<data>
<fields>
<id>g3</id>
<dat>data3</dat>
</fields>
<fields>
<id>g4</id>
<dat>data4</dat>
</fields>
<fields>
<dat>data5</dat>
</fields>
</data>
</msg>
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x LEFT OUTER JOIN
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)y ON 1=1
ID DAT SEQNO ID_REAL
1 data1 1 g1
2 data2 1 g2
3 data3 1 g3
3 data4 1 g4
3 data5 Here's everything fine, now the problem:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for HPUX: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
--exactly the same environment as 11g (tables and rows)
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x LEFT OUTER JOIN
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)y ON 1=1
ID DAT SEQNO ID_REAL
1 data1 1 g1
2 data2 1 g2
3 data3 1 g3
3 data4 1 g4As you can see in 10g I don't have the last row, it seems that Oracle 10g doesn't recognize the LEFT OUTER JOIN.
Is this a bug?, Metalink says that sometimes we can have an ORA-0600 but in this case there is no error returned, just incorrect results.
Please help.
Regards.Hi A_Non.
Thanks a lot, I tried with this:
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x,
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)(+) y ;And is giving me the complete output.
Thanks again.
Regards. -
Problem with outer join/insert
I created a test case in scott schema that describes my problem. I use emp table, and I want to have one more table - emp_info - that will store some additional info about employees. Not every employee will have additional info. I can't add a field to emp table - this has to be in an additional table.
I want to display all the emp's in a swing table, and an info if it exists - of course, using outer join. Further more, I want users to be able to enter info in this same table. If info already exists in the emp_info it will be updated, if not a new record is created.
I hope you get the picture.
So, emp_info table is:
create table emp_info(empno number(4), info varchar2(10))
ALTER TABLE "SCOTT"."EMP_INFO"
ADD (CONSTRAINT "PK_EMP_INFO" PRIMARY KEY("EMPNO"))
ALTER TABLE "SCOTT"."EMP_INFO"
ADD (CONSTRAINT "FK_EMP_INFO_EMP" FOREIGN KEY("EMPNO")
REFERENCES "SCOTT"."EMP"("EMPNO"))
In Jdev I create entitiy objects for emp and emp_info, and create View object 'ViewOuter' using these two entities. emp is updatable and empinfo is updatable and reference.
SQL query for the view object is:
SELECT Emp.EMPNO, Emp.ENAME, Emp.JOB, Emp.MGR, Emp.HIREDATE,
Emp.SAL, Emp.COMM, Emp.DEPTNO, EmpInfo.EMPNO AS EMPNO1,
EmpInfo.INFO
FROM EMP Emp, EMP_INFO EmpInfo
WHERE Emp.EMPNO = EmpInfo.EMPNO(+)
I changed View row class of the ViewOuter view:
public void setInfo(String value) {
if (getEmpno1()==null) {
setEmpno1(getEmpno());
setAttributeInternal(INFO, value);
Now I create the table in swing. It works fine - if a user changes info, new record is created or existing updated etc. There is only one problem:
If I change info on an employee, and then requery the view without commiting to the database, I don't see this info. If I try to change it, I get error
(oracle.jbo.TooManyObjectsException) JBO-25013: Too many objects match the primary key oracle.jbo.Key[7499 ].
It seams that the new info is cached, but requerying the view didn't pick it up. And when it creates new row for info PK is violated.
How can I avoid this?I set up the primari key for emp_info like this:
public void setInfo(String value) {
if (getEmpno1()==null) {
setEmpno1(getEmpno());
setAttributeInternal(INFO, value);
It's set when the user enters info.
What is the difference between transaction.commit and transaction.postChanges?
Posting changes looks like good temp solution. How can I change view object, so it calls postchanges before executing query? Since I can do requery on multiple places in application, this should be handled by the view itself.
Is there any better way? -
Left outer join problem -- need feedback
using crystal 2008
haveing prolbems with a left outerjoin to get a blank field(null) to show up.
basically i have some po line have have long descriptions or text fields that i want to include with the report. Below is my sql statement. I have written a formula with a join between 2 fields to get the report to work- this does but- it leave the polines off that do not have a long description. I have tried left outer joins but seem to be having problems. The long description field where the data is actually at is under my po.line table, although serveral area have long description fields -
*one note i had to add a duplicate table to the field to get some items in my header to work properly - not sure if this is effecting the report or not.
OK- when I set up the link to a LO join enforce from = to
and dont add the ldtext.field to the report the left outjoin works(but no long description)and all my line items show up.
1. when I keep the same join and add either just the ld.text field to the report it comes back with a error saying invalid table
2. when i use my formula that joins the ld.text and po.line and place it in the report with the same left outerjoin i get the same failure.
3. when i dont reference the ldtext(field) at all in the report it works fine w/ the lo join
4. when i Dont use a left outer join and use my formula(see below)
if not isnull(({LONGDESCRIPTION.LDTEXT }))
then {POLINE.DESCRIPTION}+{LONGDESCRIPTION.LDTEXT}
else {POLINE.DESCRIPTION}
and link from poline.ld
to ld.ldtext - my formula works and populates the po.line and the ld.text together - except that any po.line with no description will not show up. Like its not there.
Not sure what to do?
here is my current sql statement with the longdescription field in the select statement
here is the error statement i am getting:
Failed to retrieve data from the database:
Details:42000[intersolv][odb sql base driver][sql base] 00906 itn invalid table name[database vendor code:906]
sql statement:
SELECT "PO"."PONUM", "PO"."STATUS", "PO"."VENDOR",
"COMPANIES"."NAME", "COMPANIES"."ADDRESS1",
"COMPANIES"."ADDRESS2", "COMPANIES"."ADDRESS3",
"COMPANIES"."ADDRESS4", "COMPANIES"."PHONE",
"COMPANIES"."FAX", "COMPANIES_1"."NAME",
"COMPANIES_1"."ADDRESS1", "COMPANIES_1"."ADDRESS2",
"COMPANIES_1"."ADDRESS3", "COMPANIES_1"."ADDRESS4",
"COMPANIES_1"."CONTACT", "COMPANIES_1"."PHONE",
"COMPANIES_1"."FAX", "PO"."PURCHASEAGENT",
"PO"."ORDERDATE",
"PO"."REQUIREDDATE", "PO"."PAYMENTTERMS",
"PO"."SHIPVIA", "PO"."FREIGHTTERMS", "PO"."FOB",
"POLINE"."DESCRIPTION", "POLINE"."ITEMNUM",
"POLINE"."ORDERQTY", "POLINE"."UNITCOST",
"POLINE"."LOADEDCOST", "POLINE"."POLINENUM",
"PO"."SHIPTOATTN", "LONGDESCRIPTION"."LDTEXT"
FROM ("MAXIMO"."PO" "PO" LEFT OUTER JOIN
"MAXIMO"."LONGDESCRIPTION" "LONGDESCRIPTION" ON "PO"."LDKEY"="LONGDESCRIPTION"."LDKEY"),
"MAXIMO"."POLINE" "POLINE",
"MAXIMO"."COMPANIES" "COMPANIES_1",
"MAXIMO"."COMPANIES" "COMPANIES"
WHERE ("PO"."PONUM"="POLINE"."PONUM") AND ("PO"."VENDOR"="COMPANIES_1"."COMPANY") AND ("PO"."SHIPTO"="COMPANIES"."COMPANY") AND "PO"."PONUM"='3386-053'If you took the time to read this thanks.... turns out... and I just want to pull my hair out over this. My connection had a old odbc driver so somehow it would not allow a left outer join....go figure - weeks of agony over that..... thanks ....have to say love this forum.
Maybe you are looking for
-
Checkboxes:check the dish in one table-it checks off ingredients in another
If you select a dish from a table of recipes (via checkbox) can you make it select all the ingredients for that dish from another table, your master ingredients list? I think it has to do with Boolean true/false, but checkboxes seems weird to me...th
-
IPrint app on iPhone 4 cant see WiFi printer HP D110
bought and correctly installed HP D110 wifi printer and wirelessly configured to two windows pc's in my home - working fine. i have HP iPrint 3.0 on my iPhone 4 and when i try to print a photo from the iPhone 4 it says no printers available. the iPho
-
Noticed MySearchdial had hijacked by search box. Checked and found extension had been added. Deleted extenion, deleted from search engines, reset everything I could. But I noticed many references to "mysearchdial" in the about:config section of Firef
-
My husband has a Mac (and ipod) and I just got an ipod and downloaded music files from the Mac. Can I also load itunes on my pc and add music from my computer? Or do I have to always use the Mac?
-
Table Store Table Format in SBO Plzzz
i have a problem when apply to condition to delivery form (140). When I Manipulate Matrix Table Line Item (oTmpForm.Items("38").Specific.Columns.Item("1").Editable = False ) then it will be the default setting for sbo (Press Ctrl+B in Form to Check I