Oj syntax for outer join

Is there a way to make Crystal Reports XI not generate the {oj .....   syntax for outer joins?
In Crystal Reports 8, you could do a registry change to keep CR from using oj, but that doesn't seem to work on CR XI (or I don't know where to make the registry change)

A: oj syntax for outer join

Outer Join Escape Sequence builds the syntax for ODBC drivers using the outer join syntax in its SQL syntax.
Use Regedit on the problem client machine add following keys:
STEP 1........For Crystal Reports 9: HKEY_CURRENT_USER\Software\Crystal Decisions\9.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
<<<OR>>>
...................For Crystal Reports 10:HKEY_CURRENT_USER\Software\Crystal Decisions\10.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
STEP 2........"MSOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that support Microsoft ODBC {oj ..} join escape sequence.
"NoOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that do not support any join escape sequence.
For example...
MSOuterJoinEscSeq = "UVODBC"

Outer Join Escape Sequence builds the syntax for ODBC drivers using the outer join syntax in its SQL syntax.
Use Regedit on the problem client machine add following keys:
STEP 1........For Crystal Reports 9: HKEY_CURRENT_USER\Software\Crystal Decisions\9.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
<<<OR>>>
...................For Crystal Reports 10:HKEY_CURRENT_USER\Software\Crystal Decisions\10.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
STEP 2........"MSOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that support Microsoft ODBC {oj ..} join escape sequence.
"NoOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that do not support any join escape sequence.
For example...
MSOuterJoinEscSeq = "UVODBC"

Similar Messages

  • Newbie: Syntax for OUTER joins

    Hello there,
    I'm trying to write some very simple ANSI outer joins using quest's TOAD software but I keep running into syntax errors.
    Take the following classic text book example
    Find all customers who have not placed an order
    SELECT c.customerid, o.orderid
    FROM customers c
    LEFT OUTER JOIN orders o
    ON c.customerid = o.customerid
    WHERE o.orderid IS NULL
    alternative syntax supported by SQL Server
    SELECT c.customerid, o.orderid
    FROM customers c, orders o
    WHERE c.customerid *= o.customerid AND o.orderid IS NULL
    How do you write the above style of statements. Can you write RIGHT JOIN and FULL JOIN statements? What about CROSS JOIN statements
    Cheers,
    Colin Rippey
    null

    SELECT c.customerid, o.orderid
    FROM customers c, orders o
    WHERE
    c.customerid = o.customerid(+) and
    o.orderid IS NULL
    null

  • While using the Old syntax of outer join i encountered Ora-01719 error .

    This is quite strange when i used the Old way of using Outer Joins(+), i encountered the Ora-01719 error saying Outer Joins not allowed in Or and IN operator.Whereas when i use the ANSI sql i query gets executed without any error.Any idea what might be the reason..is it that i myself is making mistake.
    Please find the select statement below..
    SELECT d4.c2, d4.c8, vw_rpt_prod_ln_grp.prod_grp_desc, d4.c10, d4.c5, d4.c3,
    CASE
    WHEN d4.c6 = 'Closed'
    THEN d4.c6
    WHEN d4.c6 = 'Closed (w/o Action)'
    THEN d4.c6
    WHEN d4.c6 =
    'Closed, Supporting Process(es) Active'
    THEN d4.c6
    WHEN d4.c6 = 'Cancelled'
    THEN d4.c6
    WHEN t3.workflow_compnt_id = 1
    THEN 'Definition'
    WHEN t3.workflow_compnt_id = 2
    THEN 'Root Cause'
    WHEN t3.workflow_compnt_id = 3
    THEN 'Solution'
    WHEN t3.workflow_compnt_id = 4
    THEN 'Implementation'
    WHEN t3.workflow_compnt_id = 5
    THEN 'Feedback'
    WHEN t3.workflow_compnt_id = 9
    THEN 'Preliminary Root Cause'
    WHEN t3.workflow_compnt_id = 2001
    THEN 'Report'
    WHEN t3.workflow_compnt_id = 2002
    THEN 'Sent'
    WHEN t3.workflow_compnt_id = 2003
    THEN 'Add. Info Needed'
    WHEN t3.workflow_compnt_id = 2004
    THEN 'Open'
    WHEN t3.workflow_compnt_id = 2007
    THEN 'Solution Feedback'
    END issue_workflow_status,
    CASE
    WHEN d4.c6 = 'Closed'
    THEN 0
    WHEN d4.c6 = 'Closed (w/o Action)'
    THEN 0
    WHEN d4.c6 =
    'Closed, Supporting Process(es) Active'
    THEN 0
    WHEN d4.c6 = 'Cancelled'
    THEN 0
    ELSE t3.workflow_compnt_id
    END issue_workflow_status_code,
    d4.c6, d4.c9,
    CASE t3.issue_step_status_cd
    WHEN 'In Progress'
    THEN t3.step_target_submit_dt
    WHEN 'Needs Additional Information'
    THEN t3.step_target_submit_dt
    WHEN 'Awaiting Approval'
    THEN t3.step_target_closed_dt
    ELSE NULL
    END target_date,
    CASE
    WHEN CASE t3.issue_step_status_cd
    WHEN 'In Progress'
    THEN t3.step_target_submit_dt
    WHEN 'Needs Additional Information'
    THEN t3.step_target_submit_dt
    WHEN 'Awaiting Approval'
    THEN t3.step_target_closed_dt
    ELSE NULL
    END IS NULL
    THEN 'N'
    WHEN CASE t3.issue_step_status_cd
    WHEN 'In Progress'
    THEN t3.step_target_submit_dt
    WHEN 'Needs Additional Information'
    THEN t3.step_target_submit_dt
    WHEN 'Awaiting Approval'
    THEN t3.step_target_closed_dt
    ELSE NULL
    END < TRUNC (CURRENT_DATE)
    THEN 'Y'
    ELSE 'N'
    END step_is_late,
    t3.orig_user_full_nm, t3.champ_user_full_nm, t3.champ_org_nm,
    vw_rpt_defntn.modl_yr_nbr, vw_rpt_vpps_lvl.level1_vpps_desc,
    vw_rpt_vpps_lvl.level2_vpps_desc, vw_rpt_vpps_lvl.level3_vpps_desc,
    vw_rpt_vpps_lvl.level4_vpps_desc,
    Mv_RPT_CONCAT_ENGN_OPTN_ALL.concat_engn_optn,
    vw_rpt_incdnt_src_three_level.level1_incdnt_src_desc,
    vw_rpt_incdnt_src_three_level.level2_incdnt_src_desc,
    vw_rpt_incdnt_src_three_level.level3_incdnt_src_desc,
    vw_rpt_warranty_labr_code.concat_warranty_labr_code_desc, d4.c4, d4.c7,
    vw_cust_survey_type.cust_survey_type_desc,
    vw_complaint_ctg.complaint_ctg_cd,
    vw_prob_main_cause.prob_main_cause_desc, soltn_step.confidence_lvl_id,
    d4.c12, d4.c13
    FROM (SELECT DISTINCT vw_rpt_issue.project_id c0,
    vw_rpt_issue.prts_prod_ln_id c1,
    vw_rpt_issue.issue_id c2,
    vw_rpt_issue.disply_issue_nbr c3,
    vw_rpt_issue.issue_sevrty_cd c4,
    vw_rpt_issue.proj_nbr c5,
    vw_rpt_issue.issue_status_cd c6,
    vw_rpt_issue.primry_metric_score_nbr c7,
    vw_rpt_issue.issue_type_cd c8, vw_rpt_issue.title c9,
    vw_rpt_issue.prts_prod_ln_desc c10,
    vw_rpt_leadtime.issue_id c11,
    vw_rpt_leadtime.definition_start_dt c12,
    vw_rpt_leadtime.definition_close_dt c13,
    vw_rpt_leadtime.root_cause_start_dt c14,
    vw_rpt_leadtime.root_cause_close_dt c15,
    vw_rpt_leadtime.solution_start_dt c16,
    vw_rpt_leadtime.solution_end_dt c17,
    vw_rpt_leadtime.implementation_start_dt c18,
    vw_rpt_leadtime.implementation_close_dt c19,
    vw_rpt_leadtime.feedback_start_dt c20,
    vw_rpt_leadtime.feedback_end_dt c21,
    vw_rpt_leadtime.prc_start_dt c22,
    vw_rpt_leadtime.prc_end_dt c23,
    defntn_step.issue_id c24,
    defntn_step.workflow_compnt_id c25,
    defntn_step.complaint_ctg_id c26,
    defntn_step.contnmt_actn_plan_id c27,
    defntn_step.direct_run_imprvm_pct c28,
    defntn_step.direct_run_loss_pct c29,
    defntn_step.drive_type_id c30,
    defntn_step.driving_cond_id c31,
    defntn_step.eng_pgm_nbr c32,
    defntn_step.engn_serial_nbr c33,
    defntn_step.envrnmtl_cond_id c34,
    defntn_step.ergo_rating_id c35,
    defntn_step.evaltn_complt_pct c36,
    defntn_step.evaltn_procdr_id c37,
    defntn_step.gca_50_or_safety_issue_flag c38,
    defntn_step.gca_value_amt c39,
    defntn_step.gm_rating_id c40,
    defntn_step.hardware_stage_id c41,
    defntn_step.incdnt_discvrd_by_nm c42,
    defntn_step.incdnt_discvr_dept_nm c43,
    defntn_step.incdnt_discvr_ph_nbr c44,
    defntn_step.incdnt_first_rptd_dt c45,
    defntn_step.incdnt_src_id c46,
    defntn_step.intrnl_measmt_info_owner_nm c47,
    defntn_step.intrnl_measmt_plt_faclty_id c48,
    defntn_step.intrnl_measmt_rpt_dt c49,
    defntn_step.issue_clasfn_id c50,
    defntn_step.issue_ctg_id c51,
    defntn_step.issue_intgrtn_id c52,
    defntn_step.modl_yr_id c53,
    defntn_step.modl_yr_qtr_id c54,
    defntn_step.odmtr_msmt_unit_id c55,
    defntn_step.odmtr_rdng_msmt_unit_id c56,
    defntn_step.odmtr_rdng_nbr c57,
    defntn_step.odmtr_rdng_beginning_nbr c58,
    defntn_step.odmtr_rdng_ending_nbr c59,
    defntn_step.part_drblty_msmt_unit_id c60,
    defntn_step.part_drblty_nbr c61,
    defntn_step.part_test_msmt_unit_id c62,
    defntn_step.part_test_nbr c63,
    defntn_step.pe_me_trial_issue_flag c64,
    defntn_step.pim_nbr c65,
    defntn_step.plt_asmbly_doc_nbr c66,
    defntn_step.productivity_nbr c67,
    defntn_step.suspect_parts_avbl_flag c68,
    defntn_step.suspect_parts_loc_txt c69,
    defntn_step.trnsmn_serial_nbr c70,
    defntn_step.veh_ident_nbr c71,
    defntn_step.veh_proprt_nbr c72,
    defntn_step.veh_test_msmt_unit_id c73,
    defntn_step.veh_test_nbr c74,
    defntn_step.vpps_id_nbr c75,
    defntn_step.wrkstn_id c76,
    defntn_step.road_surface_id c77,
    defntn_step.cost_redctn_rpt_dt c78,
    defntn_step.cost_redctn_trackg_nbr c79,
    defntn_step.cost_redctn_type_id c80,
    defntn_step.cust_survey_dt c81,
    defntn_step.warnty_impct_rpt_dt c82,
    defntn_step.field_prod_rpt_nbr c83
    FROM (SELECT DISTINCT mv_rpt_issue_all.project_id
    project_id,
    mv_rpt_issue_all.prts_prod_ln_id
    prts_prod_ln_id,
    mv_rpt_issue_all.issue_id issue_id,
    mv_rpt_issue_all.disply_issue_nbr
    disply_issue_nbr,
    mv_rpt_issue_all.issue_sevrty_cd
    issue_sevrty_cd,
    mv_rpt_issue_all.proj_nbr proj_nbr,
    mv_rpt_issue_all.issue_status_cd
    issue_status_cd,
    mv_rpt_issue_all.primry_metric_score_nbr
    primry_metric_score_nbr,
    mv_rpt_issue_all.issue_type_cd
    issue_type_cd,
    mv_rpt_issue_all.title title,
    mv_rpt_issue_all.prts_prod_ln_desc
    prts_prod_ln_desc
    FROM mv_rpt_issue_all,
    vw_sec_acs_grp_proj acs_grp_proj
    WHERE acs_grp_proj.acs_grp_id IN
    (1,
    4,
    42,
    43,
    44,
    51,
    52,
    53,
    54,
    266,
    366,
    386,
    526,
    546,
    547,
    548,
    566,
    846,
    946,
    966,
    1006,
    1066,
    1087
    AND mv_rpt_issue_all.prts_prod_ln_id =
    acs_grp_proj.prts_prod_ln_id
    AND mv_rpt_issue_all.project_id =
    acs_grp_proj.project_id
    AND mv_rpt_issue_all.issue_type_cd =
    'Current Production') vw_rpt_issue,
    vw_rpt_leadtime,
    vw_defntn_step defntn_step
    WHERE vw_rpt_issue.issue_id = vw_rpt_leadtime.issue_id
    AND vw_rpt_issue.issue_id = defntn_step.issue_id) d4,
    vw_rpt_incdnt_src_three_level,
    vw_rpt_warranty_labr_code,
    vw_rpt_prod_ln_grp,
    (SELECT t1.issue_id issue_id, t1.workflow_compnt_id workflow_compnt_id,
    t1.issue_step_status_cd issue_step_status_cd,
    t1.step_target_closed_dt step_target_closed_dt,
    t1.step_target_submit_dt step_target_submit_dt,
    t1.orig_user_full_nm orig_user_full_nm,
    t1.champ_user_full_nm champ_user_full_nm,
    t1.champ_org_nm champ_org_nm
    FROM prts_syst.vw_rpt_issue_step_dtl_all t1
    WHERE t1.current_step_flag = 'Y') t3,
    vw_complaint_ctg,
    root_cause_step,
    vw_prob_main_cause,
    Mv_RPT_CONCAT_ENGN_OPTN_ALL,
    vw_rpt_vpps_lvl,
    soltn_step,
    vw_rpt_defntn_all vw_rpt_defntn,
    vw_cust_survey_impct_dtl cust_survey_impct_dtl,
    vw_cust_survey_type
    WHERE d4.c46 = vw_rpt_incdnt_src_three_level.level3_incdnt_src_id(+)
    Or d4.c46=vw_rpt_incdnt_src_three_level.level2_incdnt_src_id(+))
    And vw_rpt_incdnt_src_three_level.level3_incdnt_src_id IS NULL
    AND d4.c2 = vw_rpt_warranty_labr_code.issue_id(+)
    AND d4.c1 = vw_rpt_prod_ln_grp.prts_prod_ln_id(+)
    AND d4.c2 = t3.issue_id(+)
    AND d4.c26 = vw_complaint_ctg.complaint_ctg_id(+)
    AND d4.c2 = root_cause_step.issue_id(+)
    AND root_cause_step.prob_main_cause_id = vw_prob_main_cause.prob_main_cause_id(+)
    AND d4.c2 = Mv_RPT_CONCAT_ENGN_OPTN_ALL.issue_id(+)
    AND d4.c75 = vw_rpt_vpps_lvl.vpps_id_nbr(+)
    AND d4.c2 = soltn_step.issue_id(+)
    AND d4.c2 = vw_rpt_defntn.issue_id(+)
    AND d4.c2 = cust_survey_impct_dtl.issue_id(+)
    AND cust_survey_impct_dtl.cust_survey_type_id = vw_cust_survey_type.cust_survey_type_id(+)
    AND vw_rpt_prod_ln_grp.prod_grp_desc IN
    ('DB Admin', 'GM - All Vehicles', 'GMAP - DAT', 'GMAP - Holden')
    AND d4.c6 IN
    ('Cancelled',
    'Closed',
    'Closed (w/o Action)',
    'Closed, Supporting Process(es) Active',
    'Draft',
    'Open'
    );

    Hi,
    Maestro_Vineet wrote:
    This is quite strange when i used the Old way of using Outer Joins(+), i encountered the Ora-01719 error saying Outer Joins not allowed in Or and IN operator.Whereas when i use the ANSI sql i query gets executed without any error.Any idea what might be the reason..is it that i myself is making mistake.No, I don't think you're making any mistake. Some things are simply not allowed with the "+" outer-join syntax.
    There are work-arounds, but they are harder to code and slower to run than simply using ANSI syntax.
    I recommend always using ANSI syntax, especially for outer joins.

  • 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 32

    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, '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.

  • Return all Groups for Outer Join + Count + Group By

    I have two tables, TC and XEA. The relationship is one TC to many XEA. TC is a lookup table and has one field, the code field TCSI_CD. XEA has the same code field called BAM_TCSI, which is the joining key, and also another field, the date field, LOAD_DATE.
    I want to generate a report counting the records in XEA and grouping by the code list in TC. When a TC code is not found in XEA, the report must show a count of zero. The SQL shown does not work, as codes not found in XEA are omitted. Thanks in advance for any help.
    SELECT
    TC.TCSI_CD,DECODE(COUNT(XEA.BAM_TCSI),NULL,0,COUNT(XEA.BAM_TCSI))
    FROM
    OB_TCSI_CD TC,
    TEMP_OB_XEA_HIST XEA
    WHERE
    TC.TCSI_CD = XEA.BAM_TCSI(+) AND
    XEA.LOAD_DATE > '1-JUN-2002'
    GROUP BY
    TC.TCSI_CD

    You need to include a (+) after the load_date column. If you omit that, it negates the whole outer join and turns your query into an inner join. Then just a regular count will work, returning 0 for the null values. You also might want to use the to_date function, instead of relying on your session having the matching nls_date_format.
    SELECT   tc.tcsi_cd,
             COUNT (xea.bam_tcsi)
    FROM     ob_tcsi_cd       tc,
             temp_ob_xea_hist xea
    WHERE    tc.tcsi_cd = xea.bam_tcsi (+)
    AND      xea.load_date (+) > TO_DATE ('1-JUN-2002', 'DD-MON-YYYY')
    GROUP BY tc.tcsi_cd

  • Compatible query for outer join..

    SELECT e.ename, a.street_address, a.city,a.state,a.post_code
    FROM emp e, addr a
    WHERE e.empno = a.empno(+)
    AND a.state = 'TEXAS'
    Which is the compatible ANSI/ISO query for the above mentioned query (A or B)
    A)
    SELECT e.ename, a.street_address, a.city,a.state,a.post_code
    FROM emp e RIGHT OUTER JOIN addr a
    ON (e.empno = a.empno)
    AND a.state = 'TEXAS'
    B)
    SELECT e.ename, a.street_address, a.city,a.state,a.post_code
    FROM emp e LEFT OUTER JOIN addr a
    ON (e.empno = a.empno)
    AND a.state = 'TEXAS'
    Thanks
    Sameer

    B)
    SELECT e.ename, a.street_address, a.city,a.state,a.post_code
    FROM emp e LEFT OUTER JOIN addr a
    ON (e.empno = a.empno)
    AND a.state = 'TEXAS'
    http://www.oracle.com/oramag/oracle/01-nov/index.html?o61sql.html
    You posted this question three times. Please post each question only once. Sometimes there is a delay from the time that you click on submit until the time that the post is displayed.

  • Alternative for OUTER Join for use in fast refresh materialized view

    Hi ,
    I have two tables as :
    CREATE TABLE TEST_SANDY1
    COL1 NUMBER
    CREATE TABLE TEST_SANDY2
    COL1 NUMBER,
    COL2 VARCHAR2(10 BYTE)
    Data for the tables are :
    INSERT INTO TEST_SANDY1 ( COL1 ) VALUES (
    1);
    INSERT INTO TEST_SANDY1 ( COL1 ) VALUES (
    2);
    INSERT INTO TEST_SANDY1 ( COL1 ) VALUES (
    3);
    COMMIT;
    INSERT INTO TEST_SANDY2 ( COL1, COL2 ) VALUES (
    1, 'a');
    INSERT INTO TEST_SANDY2 ( COL1, COL2 ) VALUES (
    2, 'b');
    INSERT INTO TEST_SANDY2 ( COL1, COL2 ) VALUES (
    4, 'd');
    COMMIT;
    Now when I run the following select statement :
    select
    b.col1
    from
    test_sandy1 a,
    test_sandy2 b
    where
    b.COL1 = a.COL1(+)
    I get :
    COL1
    1
    2
    4
    I want to build a materialized view to generate the same values but it has to be fast refresh. But since I am using outer join I am unable to create a fast refresh one.
    Can someone suggest an alternate select to create fast refresh materialized view.
    Thanks,
    Sandipan

    The select statement was not fitting my problem , so I'll change it as :
    select
    a.col1, nvl(b.col2, 'DEFAULT')
    from
    test_sandy1 a,
    test_sandy2 b
    where
    b.COL1(+) = a.COL1
    I get :
    COL1     VAL
    1     a
    2     b
    3     DEFAULT
    How do I this ?

  • Performance for outer join

    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_code

    Hi,
    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.

  • Strange result for outer join with rownum

    I'm using rownum in join condition of left outer join query but i'm getting strange results.
    Query is:
    Select * from table1 left outer join table2 on table1.id = table2.id or rownum=1
    Data in table1 is
    id
    7
    8
    9
    Data in table2 is
    id
    10
    11
    12
    Result of above query in Oracle 9.2.0.1 is
    table1.id table2.id
    7 10
    7 11
    7 12
    8 10
    8 11
    8 12
    9 10
    9 11
    9 12
    Even if change is rownum related condition to like rownum >2 even than i'm getting same result.
    In case of inner join, the above condition gives results as required.
    Can anybody explain the result or is it a bug?

    could you please explain why you are using rownum.
    You may have a look at the following link explaining rownum and you should understand why you got this result, keep in mind that you are using an OR condition.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/sql_elements6a.htm#4295

  • What is syntax for inner join of Select statement with  Secondary Index

    Hi Genies,
                    Here i have created the Secondary index for table COEP and also used for select query but there is no improvement in runtime . taking same time for select query without index as well as with index. my code is
    SELECT *  INTO CORRESPONDING FIELDS OF TABLE ITAB_COEP FROM COEP AS A
                 INNER JOIN COBK  AS B ON ( A~BELNR = B~BELNR AND A~KOKRS = B~KOKRS AND A~GJAHR = B~GJAHR )
                 WHERE A~OBJNR = OBJNR
                 AND A~GJAHR = CURRY
                 AND B~GJAHR = CURRY
                 AND A~RBEST = ''
                 AND A~BEKNZ = 'S'
                 AND B~BELNR NE WA_COBK-BELNR
                 AND B~AWREF_REV = ''
                 AND B~AWORG_REV = ''
                 AND B~KOKRS = WA_COIOB-KOKRS
                 AND B~BLDAT BETWEEN START_DATE AND END_DATE
                 AND B~BLART IN ('SA','KA','KR','AB')  %_HINTS ORACLE 'INDEX("COEP" "COEP~ZBU")'.
    index name is ZBU.
    please any one let me know is there any syntax mistakes? but while checking and during the runtime it does'nt shows any error.
    Regards,
            Thangam.P

    Hi Genies,
                    Here i have created the Secondary index for table COEP and also used for select query but there is no improvement in runtime . taking same time for select query without index as well as with index. my code is
    SELECT *  INTO CORRESPONDING FIELDS OF TABLE ITAB_COEP FROM COEP AS A
                 INNER JOIN COBK  AS B ON ( A~BELNR = B~BELNR AND A~KOKRS = B~KOKRS AND A~GJAHR = B~GJAHR )
                 WHERE A~OBJNR = OBJNR
                 AND A~GJAHR = CURRY
                 AND B~GJAHR = CURRY
                 AND A~RBEST = ''
                 AND A~BEKNZ = 'S'
                 AND B~BELNR NE WA_COBK-BELNR
                 AND B~AWREF_REV = ''
                 AND B~AWORG_REV = ''
                 AND B~KOKRS = WA_COIOB-KOKRS
                 AND B~BLDAT BETWEEN START_DATE AND END_DATE
                 AND B~BLART IN ('SA','KA','KR','AB')  %_HINTS ORACLE 'INDEX("COEP" "COEP~ZBU")'.
    index name is ZBU.
    please any one let me know is there any syntax mistakes? but while checking and during the runtime it does'nt shows any error.
    Regards,
            Thangam.P

  • Query Plan Question for Outer Join

    I have the following join query:
    select unique ep.ACT_UID,
    ep.SE_REQ_TS,
    sr.SERVICE_NM
    from
    eaisvcs.Service_requests sr,
    eaisvcs.SERVICE_EPISODE ep
    where
    ep.ACT_UID = sr.ACT_UID;
    I have an index on the act_uid in both tables, and the statistics are up-to-date. There are about 3.2 million rows in each table. 10% of the act_uid's that are in the ep table that do not have a match in the sr table. Other than that, most id's match up between the tables.
    Here is the query plan:
    ID PARENT_ID OPERATION OPTIONS
    0 SELECT STATEMENT
    1 0 SORT UNIQUE
    2 1 MERGE JOIN
    3 2 SORT JOIN
    4 3 TABLE ACCESS FULL
    5 2 SORT JOIN
    6 5 TABLE ACCESS FULL
    I cannot figure out why a table scan is being performed every time on both tables. The Act_UID is the PK in the ep table. There is a composite index (act_uid, sev_seq_no) in the sr table. the act_id is a varchar2 column in both tables. The sev_seq_no column is numeric.
    Any ideas or insights about this would be greatly appreciated.
    Thanks!

    The plan can be good.
    Oracle choose a full table scan for these reason too:
    - sr.SERVICE_NM is not a part of the index and so a full table scan is less expensive. If you will add this field to your composite index Oracle will probably take this new index.
    Bye, Aron

  • Help need for Outer Join Query Mysterious Query...

    I have two table parent tablea and child tableb
    Now
    tableb has field by name table_id,keyword_name,keyword_value
    tablea has field by name
    table_id,table_name
    I need a query which would retrieve union of this two set...(for table_name)
    1)all table_name having keyword_name='abc' and value=12
    2)all the table_name that does not have 'abc' as keyword in tableb.....
    Please let me know how it can be done....

    Ok then, try this.
    select
        a.table_name
    from
        tablea a, tableb b
    where
        a.table_id = b.table_id
        and b.keyword_name = 'abc'
        and b.value = 12
    union
    select
        c.table_name
    from
        tablea c
    where
        not exists (select 1 from tableb d
                    where d.table_id = c.table_id
                          and d.keyword_name = 'abc'
                   ) ;To get a faster answer and avoid wrong guesses, I always find it helpful to show sample data and sample output when asking a SQL question. For example:
    TableA -----------------
    table_id    table_name
      1           AAA
      2           BBB
      3           CCC
      4           DDD
      5           EEE
    TableB -----------------
    table_id    keyword_name   value
        1             abc       12
        1             def       23
        2             abc       13
        4             def       12
        5             abc       13
        5             def       12
    Desired output of query: -----------------
    AAA
    CCC
    DDD

  • OBIEE not applying outer join syntax to filters

    (Note: I've already thoroughly searched the forums before posting this. Thanks)
    My problem is the following:
    I'm trying to build a report that is a count from my fact table, grouped by month from my date dimension for a given year, resulting in 12 data points. The problem is that not all months have actual data, but I still need those months to show on the report with a count of zero. Typical simple reporting requirement.
    I have already done the obvious and within my business layer made the join between my fact table and my date dimension an outer join on the fact side, just like you'd do if writing the query by hand. And when tested by hand this includes all dates for the year anyway, and when coupled with the appropriate null test on the count measure I'd get my 12 data points with zeros were appropriate.
    The problem is that there are additional filters I need to apply on the fact data (there are a couple text-based code values that didn't warrant full tables themselves so are just degenerate dimensions directly on the fact table.)
    When these filters are applied at the Answer level, I'm only getting back the months that actually have data, and lose the months where the count should be zero. A check of the session log for the query that was generated shows the problem. While OBI properly generates the outer-join syntax for the join itself between the two tables (my date dim and fact table) it does NOT apply the outer-syntax to the constant-based filter against the fact, effectively negating the outer join.
    Actual query from the log (I simply changed the table aliases from the ugly T##### stuff OBI generates to something more readable for posting here):
    select D.DT_MONTH_NAME as c1,
    D.DT_MONTH_NUM as c2,
    I.INC_TYPE as c3,
    I.INC_EMP_GROUP as c4,
    sum(case when I.INC_KEY is null then 0 else 1 end ) as c5
    from DATE_DIM D, INCIDENT_F I
    where ( D.DATE_KEY = I.DATE_KEY (+) ) and ( D.DT_YEAR = 2010 and I.INC_EMP_GROUP = 'CONTRACTOR' )
    group by D.DT_MONTH_NUM, D.DT_MONTH_NAME, I.INC_TYPE, I.INC_EMP_GROUP
    order by c2
    You can see that the outer syntax (+) is applied to the join, but not to the filter on I.INC_EMP_GROUP. If I take this query and drop it in something like SQL Developer, it only returns the months with data. If I throw the (+) after I.INC_EMP_GROUP like I'd do if writing this by hand, the desired zero-months results pop back in.
    I have already searched the forums and while lots of people seem to have asked this question, the only solutions involve things like trickery in the business layer using dummy fact tables followed by manipulations at the report level etc. Unfortunately I can't rely on these as the system is eventually to be turned over to users who can't be expected to apply various hacks to write reports.
    Anyone ever get to the bottom of getting OBI to apply outer join logic in filters as well, when the filtered table is meant to be outer-joined to?
    Any comments are appreciated.
    John

    I know that this thread is a bit old thought it might be helpful to some one...
    The Issue is, when using Degener@teDimen$ion ( this is !nner joned to FACT tables in BMM) and if any of the dimensions {other than theDegener@teDimen$ion (Let us say Dim X) } have an ()uter join to any of the fact tables, and you were doing your analysis using Degener@teDimen$ion,  Dim X, Measure value you will face the following issues.
    when filtering the analysis on the ()uter join dimension ( Dim X), the IN filter will not work. Reason is that the filter is getting applied to both the Dimension and FACT tables and the values that exist in Dimension Dim X but not in FACT table wont show up.
         The above issue can be fixed by changing the join between the fact and Degener@teDimen$ion from inner to outer. I think this is a bug.. because  it is supposed to filter the fact  table after the entire outer joined result is obtained but not filter the fact table for the Dim X values and do a outer join. I think the BI should be intelligent enough.

  • LEFT OUTER JOIN multiple tables - using the 9i syntax

    I've always written my queries using the (+) operator for outer joins. I want to start using the new ANSI standard available in 9i. I can do it when I'm joining two tables in a simple query, but how does it work when I am joining multiple tables?
    Here is an example of some SQL that works with the (+) outer join syntax. How can I convert this to use the LEFT OUTER JOIN syntax?
    SELECT *
    FROM audit_entry aue,
    audit_table aut,
    audit_statement aus,
    audit_row aur,
    audit_row_pkey aup1,
    audit_row_pkey aup2
    WHERE aue.audit_entry_id = aus.audit_entry_id
    AND aut.table_name = 'TEST_AUDITING'
    AND aut.table_owner = 'CLA_JOURNAL'
    AND aus.audit_table_id = aut.audit_table_id
    AND aur.audit_statement_id (+) = aus.audit_statement_id
    AND aup1.audit_row_id (+) = aur.audit_row_id
    AND aup1.pk_column_name (+) = 'TEST_AUDTING_PK_1'
    AND aup2.audit_row_id (+) = aur.audit_row_id
    AND aup2.pk_column_name (+) = 'TEST_AUDITING_PK_2'
    I can join audit_statement to audit_entry easy enough, but then I want to join audit_table to audit_statement, how do I do that, do I start nesting the join statements?
    Thanks
    Richard

    Thanks for getting back so quickly, I have tried the suggested SQL with mixed results:
    SELECT COUNT(*)
    FROM audit_entry aue
    JOIN audit_statement aus ON aue.audit_entry_id = aus.audit_entry_id
    JOIN audit_table aut ON aus.audit_table_id = aut.audit_table_id
    RIGHT OUTER JOIN audit_row aur ON aur.audit_statement_id = aus.audit_statement_id
    RIGHT OUTER JOIN audit_row_pkey aup1 ON aup1.audit_row_id = aur.audit_row_id
    RIGHT OUTER JOIN audit_row_pkey aup2 ON aup2.audit_row_id = aur.audit_row_id
    WHERE aut.table_name = 'TEST_AUDITING_TWO'
    AND aut.table_owner = 'CLA_JOURNAL'
    AND aup1.pk_column_name = 'TEST_AUDTING_PK_1'
    AND aup2.pk_column_name = 'TEST_AUDITING_PK_2'
    I had to change the order slightly, between the first two JOINs but otherwise it executed OK. My problem is, it should only return 175 rows but its returning 30625 rows. If I comment out the second reference to audit_row_pkey I get the expected result:
    SELECT COUNT(*)
    FROM audit_entry aue
    JOIN audit_statement aus ON aue.audit_entry_id = aus.audit_entry_id
    JOIN audit_table aut ON aus.audit_table_id = aut.audit_table_id
    RIGHT OUTER JOIN audit_row aur ON aur.audit_statement_id = aus.audit_statement_id
    RIGHT OUTER JOIN audit_row_pkey aup1 ON aup1.audit_row_id = aur.audit_row_id
    --RIGHT OUTER JOIN audit_row_pkey aup2 ON aup2.audit_row_id = aur.audit_row_id
    WHERE aut.table_name = 'TEST_AUDITING_TWO'
    AND aut.table_owner = 'CLA_JOURNAL'
    AND aup1.pk_column_name = 'TEST_AUDTING_PK_1'
    --AND aup2.pk_column_name = 'TEST_AUDITING_PK_2'
    It looks the same condition is being used in each case but why do I suddenly get so many rows - its joining differently somehow. It must be to do with the order, do I need to bracket the query?
    Thanks again
    Richard

  • LEFT OUTER JOIN SQL syntax

    Haven't seen a solution to this on the forum or in the docs. My last post timed out with no responses, but I still don't know if I have a possible solution.
    I've got 2 objects, Task and Role, that are linked in a M-M relationship.
    My tables are:
    T_TASKS
    T_TASKSROLES
    T_ROLES
    I am querying T_TASKS and joining on T_TASKSROLES and T_ROLES, but I need to use an outer join because not all Tasks have a Role in T_TASKSROLES.
    In SQL Server, my FROM clause SHOULD look like this:
    FROM (T_TASKSROLES t2 LEFT OUTER JOIN T_TASKS t1 ON t1.ID = t2.TASKID) LEFT OUTER JOIN T_ROLES t0 ON t0.ID = t2.ROLEID
    however, if I use eb.anyOfAllowingNone(_roles) in my ExpressionBuilder. TopLink creates a LEFT OUTER JOIN clause that looks like this:
    FROM T_ROLES t0 LEFT OUTER JOIN T_TASKS t1 ON((t0.ID = T_TASKSROLES.ROLEID) AND (t1.ID = T_TASKSROLES.TASKID))
    I can see the logic in how it builds this clause. But, it doesn't parse in SQL Server.
    Is there a way to effect how TopLink generates the FROM clause for outer joins? I mean, I understand how to use the XXXPlatform.java source files and can change whether to use OuterJoin in the WHERE clause or not. But, I can't see anything in the platform class that would allow me to figure this out.
    I realize I could write SQL manually, but is there a way to do this so that the same code would work on SQL Server, Oracle, and Sybase (assuming the DatabaseLogin is configured appropriately)?
    It just seems like LEFT OUTER JOIN when joining M-M relationships isn't generating proper SQL. Is the TopLink SQL SQL92-compliant?
    I should add that I have tried to change SQLServerPlatform to have shouldPrintOuterJoinInWhereClause() return "true". This embeds a "=*" in the join conditions in the WHERE clause.
    SQL Server 2000 still supports this syntax, but the "=*" isn't ALWAYS the correct operator. It is important to put the "*" on the correct side of the expression. TopLink always prints "=*", but the operators are not always in the correct order. So, it tries to create a "left join" on the wrong table.
    So my other question, is it possible to force TopLink to remember to put the outer join table in the RIGHT SIDE?
    Nate

    The workaround is actually more complicated than that, and it can't be fixed by changing only the operator.
    In the queries you listed, the only difference is which side of the "AND" the expressions appear on.
    Change "(t2.rightid (+)= t1.rightid)" to "(t1.rightid (+)= t2.rightid)" and I'm guessing (although not sure because I am testing with SQL Server at the moment), that you'll get a similar query error as I did.
    The bug here is that the default M-M selection criteria creates "reltable = table1 AND table2 = reltable". There is no operator that can satisfy this expression.
    So, the fix that I made, for all of my M-M Mappings was to set the SelectionCriteria manually using the following Expression (returned from this method):
    // This puts M-M relationship tables on the same side of expressions so that OUTER JOINS can be supported.
    private Expression getSameSideExpression() {
              // target side
              Expression selectionCriteria = null;
    Enumeration e2 = getTargetKeyFields().elements();
    Enumeration e = getTargetRelationKeyFields().elements();
    ExpressionBuilder eb = new ExpressionBuilder();
    Expression relTableExp = null;
    while(e2.hasMoreElements()) {
    DatabaseField df = (DatabaseField) e.nextElement();
    DatabaseField df2 = (DatabaseField) e2.nextElement();
    if(relTableExp == null){
    relTableExp = eb.getTable(df.getTable());
    Expression targetFieldExp = eb.getField(df2);
    Expression relFieldExp = relTableExp.getField(df);
    Expression joinExp = relFieldExp.equal(targetFieldExp);
    if(selectionCriteria == null)
    selectionCriteria = joinExp;
    else
    selectionCriteria = joinExp.and(selectionCriteria);
              // source side
    e = getSourceRelationKeyFields().elements();
              e2 = getSourceKeyFields().elements();
    while(e.hasMoreElements()) {
    DatabaseField df = (DatabaseField) e.nextElement();
    DatabaseField df2 = (DatabaseField) e2.nextElement();
    Expression relFieldExp = relTableExp.getField(df);
    Expression sourceFieldExp = eb.getParameter(df2);
    Expression joinExp = relFieldExp.equal(sourceFieldExp);
    if(selectionCriteria == null)
                        selectionCriteria = joinExp;
    else
    selectionCriteria = joinExp.and(selectionCriteria);
              return selectionCriteria;
    This changes the M-M Selection Criteria to "table1 = reltable AND table2 = reltable". Now that this is consistent, using the WHERE clause for my joins in SQL Server is possible.
    If you can think of any other problems this change may have, please let me know.
    Thanks for the help.
    Nate

Maybe you are looking for