ANSI SQL Syntax Vs Old Syntax

Hi,
Is there a performance difference between ansi and old syntax.
The following query
SELECT ITD.display_description
FROM structure_child SC
RIGHT OUTER JOIN structure S ON SC.structure_id = S.structure_id
INNER JOIN structure_level SL ON SL.structure_level_id = S.structure_level_id
INNER JOIN item_type_naming ITN ON ITN.structure_id = S.structure_id
INNER JOIN item_type_description ITD ON ITN.item_type_description_id = ITD.item_type_description_id
AND item_type_id = p_item_type_id
WHERE ( S.structure_id = p_structure_id OR S.structure_id = 0)
and itd.item_type_id = p_item_type_id
ORDER BY structure_level
Runs much slower than the old style query
SELECT ITD.DISPLAY_DESCRIPTION
FROM structure S, structure_child SC, structure_level SL,item_type_naming ITN,
item_type_description ITD
WHERE SC.structure_id(+) = S.structure_id
AND SL.structure_level_id = S.structure_level_id
AND ITN.structure_id = S.structure_id
AND ITN.item_type_description_id = ITD.item_type_description_id
AND item_type_id = p_item_type_id
AND (S.structure_id = p_structure_id OR S.structure_id = 0)
ORDER BY structure_level
Any reasons why this is the case. Also is there any hint I can give to improve the performance.

They ought to be the same.
Be sure to run the query twice to ensure the extra time doesn't including parsing, etc.
Do you get the same results?
Are the explain/execution plans the same?
The only caveat I can think of with ANSI joins is that there is a problem using them over a dblink in which one of the remote tables has a LOB column, an error is generated it that case...
Steve

Similar Messages

  • ANSI SQL to Oracle Old SQL conversion

    I need help to convert this ANSI SQL Query to Oracle Old school (With inline views and =(+) joins and where clasuses)
    CUrrent Query and new one should return same resultset
    ---------------------------------Query Start----------------------------------------------------
    SELECT COUNT(*)
    FROM
    SELECT
    'XXXXXX' as Big_Boss,
    da.Direct,
    da.Director,
    da.Manager,
    da.SubArea,
    da.Project,
    da.Project_Name,
    da.Project_Class,
    da.HISL,
    da.Resource_Name,
    da.Resource_Status,
    da.mon,
    to_char(sysdate, 'dd-Mon-YYYY') AS "Current_Date",
    DECODE(da.Project, NULL, 0, round(da.Slice / da.month_total, 2)) as
    "Approved_Demand",
    SUM(da.Availability) as "Headcount"
    FROM
    SELECT
    w.level4_name AS Direct,
    w.level5_name AS Director,
    w.level6_name AS Manager,
    w.level7_name AS SubArea,
    INV.Code as Project,
    inv.name as Project_Name,
    det.hum_project_gate as Project_Class,
    r.id AS HISL,
    r.full_name as Resource_Name,
    lookup.lookup_code as Resource_Status,
    alc.slice AS Slice,
    alc.slice_date as Mon,
    avl.slice AS month_total,
    alc.slice / avl.slice as FTE,
    count(distinct r.id) AS Availability
    FROM
    nbi_dim_obs w,
    prj_blb_slices_m_avl avl,
    prj_obs_units obs,
    cmn_lookups lookup,
    srm_resources r
    **************   Section to be Converted   ***************************----------
    ----------------------------Start----------------------------------------------------
    left outer join(prj_resources t inner join srm_resources res on
    t.prprimaryroleid = res.id) on r.id = t.prid
    left outer join(prj_blb_slices_m_alc alc
    left outer join(prteam tm
    inner join(inv_investments INV inner join odf_ca_project det on det.id = inv.id
    and det.hum_project_gate = 'approved_for_development') on tm.prprojectid = INV.ID
    and INV.Is_Active = 1) on alc.prj_object_id = tm.prid
    and alc.investment_id = inv.id) on alc.resource_id = t.prid
    --------------------------------------End--------------------------------------------
    -- inner join prj_blb_slices_m_avl avl on alc.resource_id = avl.prj_object_id
    -- inner join prj_obs_units obs on res.unique_name = obs.unique_name
    -- inner join nbi_dim_obs w on w.level7_unit_id = obs.id
    WHERE
    w.obs_type_name = 'Workgroup'
    AND alc.slice > 0
    AND alc.slice_date = avl.slice_date
    AND r.is_active = 1
    AND r.person_type = lookup.id
    AND w.level7_unit_id = obs.id
    AND alc.resource_id = avl.prj_object_id
    AND res.unique_name = obs.unique_name
    GROUP BY
    w.level4_name
    , w.level5_name
    , w.level6_name
    , w.level7_name
    , r.id
    , r.full_name
    , lookup.lookup_code
    , inv.code
    , inv.NAME
    , det.hum_project_gate
    , alc.slice_date
    , alc.slice
    , avl.slice
    ) DA
    GROUP BY
    da.direct
    , da.director
    , da.manager
    , da.subarea
    , da.project_class
    , da.hisl
    , da.resource_name
    , da.resource_status
    , da.project
    , da.Project_Name
    , da.mon
    , da.availability
    , da.slice
    , da.month_total
    ORDER BY
    da.direct
    , da.director
    , da.manager
    , da.subarea
    -------------------------------Query End----------------------------------------------------------

    Joins are joins ... what do you mean by "nested" joins?
    If you are concerned about outer joins that can be performed using ANSI syntax that are not supported in the classic Oracle syntax then use in-line view and outer join the views.
    If your code was properly formatted it would be possible for someone to read it and possibly see what you are seeing.
    Read the FAQ page and learn to format your posted code.

  • ANSI SQL 92 SYNTAX OUTER JOIN PERFORMANCE ISSUE

    Good Morning
    Could anyone explain why the excution time for these two (ment to be identical)
    queries run so differently.
    oracle syntax execution time 1.06 seconds
    select COUNT(*) from
    PL_EVENT_VIEW pev,
    PL_EVENT_STAFF_VIEW pesv
    WHERE pev.EVENT_ID=PESV.EVENT_ID(+)
    AND pev.WEEKS=PESV.WEEK_NUM(+)
    AND pev.event_id=2520
    ansi sql 92 syntax execution time 7.05 seconds
    select COUNT(*) from
    PL_EVENT_VIEW pev
    LEFT JOIN PL_EVENT_STAFF_VIEW pesv
    ON (pev.EVENT_ID=PESV.EVENT_ID
    AND pev.WEEKS=PESV.WEEK_NUM)
    WHERE pev.event_id=2520
    Thanks
    David Hills

    BTW Oracle outer join operator (+) and ANSI SQL OUTER JOIN syntax are NOT equivalent. Consider following:
    DROP TABLE T1;
    CREATE TABLE T1 (C1 NUMBER);
    DROP TABLE T2;
    CREATE TABLE T2 (C2 NUMBER);
    DROP TABLE T3;
    CREATE TABLE T3 (C3 NUMBER);
    -- Following SELECT works:
    SELECT COUNT(*)
         FROM T1, T2, T3
         WHERE C2 = C1
              AND C3(+) = C1
    COUNT(*)
    0
    -- But:
    SELECT COUNT(*)
         FROM T1, T2, T3
         WHERE C2 = C1
              AND C3(+) = C1
              AND C3(+) = C2
    AND C3(+) = C1
    ERROR at line 4:
    ORA-01417: a table may be outer joined to at most one other table
    -- However with ANSI syntax:
    SELECT COUNT(*)
         FROM T1
         JOIN T2 ON (C2 = C1)
         LEFT JOIN T3 ON (C3 = C1 AND C3 = C2)
    COUNT(*)
    0

  • ANSI SQL Syntax - What belongs to join-clause and what to where-clause

    Hello,
    we currently have a discussion about the ANSI SQL Syntax where we do not agree what belongs to the join clause and what belongs to the where clause in an ANSI Sytnax SQL Query.
    Lets say there is a query like this:
    +SELECT *+
    FROM employees emp, departments dept
    WHERE emp.dept_country = dept.dept_country
    AND emp.dept_name = dept.dept_name
    AND dept.dept_type = 'HQ'
    AND emp.emp_lastname = 'Smith'
    Primary key of the departments table is on the columns dept_country, dept_name and dept_type. We have a Oracle database 10g.
    Now I have rewritten the query to Ansi Syntax:
    +SELECT *+
    FROM employees emp
    JOIN departments dept
    ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name
    WHERE dept.dept_type = 'HQ'
    AND emp.emp_lastname = 'Smith'
    Another developer says that this is not completely correct, every filter on a column that belongs to the primary-key of the joined table has to be in the join clause, like this:
    +SELECT *+
    FROM employees emp
    JOIN departments dept
    +ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name AND dept.dept_type = 'HQ'
    WHERE emp.emp_lastname = 'Smith'
    Can somebody tell me which on is correct?
    Is there any definition for that? I couldn't find it in the Oracle Database definition.
    I just found out the names of the ANSI documents here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_standard_sql001.htm#i11939
    I had a look at the ANSI webstore but there you have to buy the PDF files. In my case thats exaggerated because both of the Queries work and i am just interessted if there is one correct way.
    Thank you in advance
    Marco

    Hi,
    As i guideline i would say, answer the question: should the result of the join be filtered or should only filtered rows be joined from a particular table?
    This is helpful in the case of outer joins also, for inner joins it doesnt matters as said already be former posters, where there may be hughe semantical differences depending of where the predicates are placed.
    From performance view, if we talk about oracle, take a look a the execution plans. You will see that there is (probably) no difference in case of inner joins. Even in case of outer joins the optimizer pushes the predicate as a filter towards the table if it semantically possible.
    Regards

  • ANSI SQL syntax?

    Hi all,
    I have a simple query
    SELECT A.*, B.Dstrct_Code FROM MSF601 A, MSF600 B
    WHERE ALTERNATE_REF LIKE 'PF%'
    AND A.alt_ref_code = B.Equip_No
    AND B.Dstrct_Code = 'ACME';
    which works fine, but I want to convert it to ANSI
    SQL syntax, so I tried
    SELECT A.*, B.Dstrct_Code FROM MSF601 A, MSF600 B
    WHERE ALTERNATE_REF LIKE 'PF%'
    INNER JOIN ON A.alt_ref_code = B.Equip_No
    AND B.Dstrct_Code = 'ACME';
    but I get
    ERROR at line 3:
    ORA-00933: SQL command not properly ended
    Could some kind soul explain why?
    Paul...

    An example that looks a lot like your example:
    SQL> select dept.*
      2       , emp.ename
      3    from dept, emp
      4   where dept.dname like '%A%'
      5   inner join on dept.deptno = emp.deptno
      6     and emp.sal > 1000
      7  /
    inner join on dept.deptno = emp.deptno
    FOUT in regel 5:
    .ORA-00933: SQL command not properly ended
    SQL> select dept.*
      2       , emp.ename
      3    from dept
      4         inner join emp on dept.deptno = emp.deptno
      5   where dept.dname like '%A%'
      6     and emp.sal > 1000
      7  /
                                    DEPTNO DNAME          LOC           ENAME
                                        30 SALES          CHICAGO       ALLEN
                                        30 SALES          CHICAGO       WARD
                                        20 RESEARCH       DALLAS        JONES
                                        30 SALES          CHICAGO       MARTIN
                                        30 SALES          CHICAGO       BLAKE
                                        10 ACCOUNTING     NEW YORK      CLARK
                                        20 RESEARCH       DALLAS        SCOTT
                                        10 ACCOUNTING     NEW YORK      KING
                                        30 SALES          CHICAGO       TURNER
                                        20 RESEARCH       DALLAS        ADAMS
                                        20 RESEARCH       DALLAS        FORD
                                        10 ACCOUNTING     NEW YORK      MILLER
    12 rijen zijn geselecteerd.Regards,
    Rob.

  • How to generate ANSI SQL syntax mapping

    I am not able to force OWB to generate ANSI SQL syntax mapping.
    In mapping configuration I have checked "ANSI SQL syntax" On, "Operating mode" is "Set based fail over to row based", "Optimize code" is On.
    "PLSQL generation mode" is set to 10gR2.
    OWB 10.2.0.4.36, OraDB 10.2.0.4.0

    Oracle SQL is based on ANSI sql 92 standards. But not possible to generate queries in ansi sql 92 format?

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

  • Help with translating SQL query from SQL Server syntax to Oracle syntax

    Hi,
    is it someone that can help me translate following SQL query from SQL Server syntax to Oracle syntax.
    SELECT ID,
    [LMT(MTR)] = MAX(case when TYPE = 'LMT' then VALUE end),
    [AAD(KGM)] = MAX(case when TYPE = 'AAD' then VALUE end),
    [VOL(MTQ)] = MAX(case when TYPE = 'VOL' then VALUE end)
    FROM yourtable
    GROUP BY ID
    Your help is highly appreciated, thanks in advance.

    Like this,
    SELECT ID,
    MAX(case when TYPE = 'LMT' then VALUE end) LMT_MTR,
    MAX(case when TYPE = 'AAD' then VALUE end) AAD_KGM ,
    MAX(case when TYPE = 'VOL' then VALUE end) VOL_MTQ
    FROM yourtable
    GROUP BY ID-Arun

  • Generate ANSI SQL with Oracle IKM

    Is it possible for ODI to generate ANSI SQL with the Oracle IKM?
    I have used ANSI joins in a filter in an interface, now when I run the interface I get the error: ORA-25156: old style outer join (+) cannot be used with ANSI joins.
    I would prefer to use ANSI joins in my filters instead of the old style (+) syntax. Is this possible?

    Sure,
    Go to topology, edit your Oracle technology , on SQL tab change it over to ordered joins - clause location - From , you can specify the keywords left join, right join, full outer join etc to get rid of your '(+)'

  • Differences between ANSI SQL and Oracle 8/9

    Hallo,
    i'm looking for good online texts or books concerning the problem "Differences between ANSI SQL and different database implementations (ORACLE, Informix, MySQL...)" I want to check a program written in C (with ESQL) that works with an Informix-DB. In this code i want to find code that is specific to the Informix-DB. I want to change the database, so all the code should be independent from a DB. Does anybody know texts or books concerning this problem?
    thx
    Marco Seum

    Basically there is syntax difference between both of them.
    Lets say i want to join two table EMP and DEPT based on DEPTNO.
    With Oracle SQL format its like this.
    select e.*
      from emp e, dept d
    where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
    With ANSI SQL format its like this.
    select e.*
      from emp e
      join dept d
        on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
    Oracle supports ANSI SQL starting from 9i version.
    You can read more about the syntax difference Here

  • What is Difference between ANSI SQL and ORACLE SQL

    Hi,
    I am going to take the assesment test for ANSI SQL Programming before that i want to know any difference between ANSI SQL and ORACLE SQL?
    I am studying for SQL but the test will be ANSI SQL please let me give an idea about the both.
    Thanks
    Merina Roslin

    Basically there is syntax difference between both of them.
    Lets say i want to join two table EMP and DEPT based on DEPTNO.
    With Oracle SQL format its like this.
    select e.*
      from emp e, dept d
    where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
    With ANSI SQL format its like this.
    select e.*
      from emp e
      join dept d
        on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
    Oracle supports ANSI SQL starting from 9i version.
    You can read more about the syntax difference Here

  • Iso/ansi sql-99 query

    hi..
    i'm new for oracle ..
    i hav one doubt .. what is the difference between normal join and iso/ansi sql-99 joins...
    is any advantage ..
    query e.g:
    SELECT c.course_name, c.period, e.student_name
    FROM course c, enrollment e
    WHERE c.course_name = e.course_name(+)
    AND c.period = e.period(+);
    sql-99 format :
    SELECT c.course_name, c.period, e.student_name
    FROM enrollment e RIGHT OUTER JOIN course c
    ON c.course_name = e.course_name
    AND c.period = e.period;

    Hi
    -It is analogous to joining a table, and avoiding the "where" clause
    -It allows easier product migration and a reduced learning curve when cross-training
    -there is no performance increase compared to the existing syntax.
    I hope u got it
    Khurram Siddiqui
    [email protected]

  • Ansi SQL for "select ... for update nowait"

    Hi, All,
    I have a sql
    select ... for update nowait
    My boss wants it to be ANSI compliant.
    I am not familiar with ANSI SQL.
    What should be the syntax in Ansi?
    Thanks a lot!

    I resent having the lowest salary :-)Sorry John, it's probably due to the exchange rate of sterling against the canuck dollar right now.
    SQL> select empno, ename, sal, job, mgr from emp;
         EMPNO ENAME             SAL JOB              MGR
          7369 SPENCER           800 CLERK           7902
          7499 VERREYNNE        1600 SALESMAN        7698
          7521 VAN WIJK         1250 SALESMAN        7698
          7566 MAINGUY          2975 MANAGER         7839
          7654 KISHORE          1250 SALESMAN        7698
          7698 BARRY            2850 MANAGER         7839
          7782 BOEHMER          2695 MANAGER         7839
          7788 PADFIELD         3000 ANALYST         7566
          7839 SCHNEIDER        5500 PRESIDENT
          7844 GASPAROTTO       1500 SALESMAN        7698
          7876 CAVE             1100 CLERK           7788
          7900 CLARKE            950 CLERK           7698
          7902 JAFFAR           3000 ANALYST         7566
          7934 ROBERTSON        1430 CLERK           7782
    14 rows selected.
    SQL> Cheers, APC

  • Oracle SQL / Ansi SQL

    Hey,
    one of my colleagues managed to create a SQL-statement (in ansi-sql-syntax) that just blocks the session and gives no response at all.
    When I rewrote the statement, it gave results within a second.
    It's not quite possible to provide a sample-case, but maybe someone here has an idea why the first statement doesn't work, and the second does?
    First:
    ====
    SELECT c.CONTRACTID as ENTITEITID,
    v.VASTSTELLINGCODE,
    '' as INFO,
    v.CAMPAGNE
    FROM NFD_CONTRACT c
    INNER JOIN NFD_OVK o ON o.OVKID = c.OVKID
    INNER JOIN NFD_VSTDEFCMP v ON v.VASTSTELLINGCODE = 'C77' AND v.CLASSIFICATIECODE = o.CLASSIFICATIECODE AND v.CAMPAGNE = o.CAMPAGNE
    AND Nfd_Vaststellingen_Pck.NFD_IS_DATUM_VST_VALID('C77',o.CAMPAGNE,'Contract',o.CLASSIFICATIECODE) = 1
    INNER JOIN NFD_BETROKKENPSN_CON psn ON c.CONTRACTID = psn.CONTRACTID
    INNER JOIN (SELECT a.aangifteid, a.psn_nmr, a.psnrolid, a.oogstjaar,
    case when exists (SELECT ENTITEITID FROM NFD_VST_OA04_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA05_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA06_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    else 0
    end AS OA_Heeft_E
    FROM NFD_AANGIFTE a
    WHERE AANGIFTETYPE = 'Oogstaangifte') vst ON psn.PSN_NMR = vst.PSN_NMR AND psn.PSNROLID = vst.PSNROLID
    AND o.CAMPAGNE = vst.OOGSTJAAR AND vst.OA_Heeft_E = 1
    Second:
    ======
    SELECT c.CONTRACTID as ENTITEITID,
    v.VASTSTELLINGCODE,
    '' as INFO,
    v.CAMPAGNE
    FROM NFD_CONTRACT c
    ,nfd_ovk o
    ,nfd_vstdefcmp v
    ,nfd_betrokkenpsn_con psn
    ,(SELECT a.aangifteid, a.psn_nmr, a.psnrolid, a.oogstjaar,
    case when exists (SELECT ENTITEITID FROM NFD_VST_OA04_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA04M_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA04S_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA05_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA06_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    else 0
    end AS OA_Heeft_E
    FROM NFD_AANGIFTE a
    WHERE AANGIFTETYPE = 'Oogstaangifte') vst
    WHERE o.OVKID = c.OVKID
    AND v.VASTSTELLINGCODE = 'C77' AND v.CLASSIFICATIECODE = o.CLASSIFICATIECODE AND v.CAMPAGNE = o.CAMPAGNE
    AND Nfd_Vaststellingen_Pck.NFD_IS_DATUM_VST_VALID('C77',o.CAMPAGNE,'Contract',o.CLASSIFICATIECODE) = 1
    AND c.CONTRACTID = psn.CONTRACTID
    AND psn.PSN_NMR = vst.PSN_NMR AND psn.PSNROLID = vst.PSNROLID
    AND o.CAMPAGNE = vst.OOGSTJAAR AND vst.OA_Heeft_E = 1

    hey riedelmie,
    off course the second statement is different.
    I rewrote the query so the inner joins are being replaced by where-clauses with the table-names all in the from-clause.
    In the second statement there are two extra when-clauses but they should also be in the first statement (the problem is still there, so data could indeed be different, but the problem is the same)
    Tnx.
    Greetings,
    Dave
    Message was edited by:
    geysemansdave
    added text about the when-clauses

  • Sys_connect_by_path_node ? [Can do this in ANSI SQL-99] - Hierarchy Query

    Hi All,
    A slighly more complex connect by problem (that can be done with ANSI SQL-99) looking for an oracle matching output.
    Input Data: (Small example subset)
    RootID | Parent_ID | FreeText
    0 | 0     |
    444 | 555 | ABC1
    555 | 666 | DEF2
    666 | 777 | GHI3
    888 | 0 | JKL4
    Output Wanted: (Small example subset)
    RootID ParentID FreeText          LEVEL (Nesting)
    444 |     555 |               |     1
    444 |     666 |     ABC1          |     2
    444 |     777 |     DEF2-ABC1     |     3
    444 |     888 |     GHI3-DEF2-ABC1      | 4
    444 |     0 |     JKL4-GHI3-DEF2-ABC1 | 5
    Can be easily enough done with ANSI-99 SYNTAX (Not supported in Oracle using a recursive CTE)
    Target platform Oracle 9i
    ANSI-SQL 99 Syntax: (Not Supported on Oracle - but demonstrates the ANSI-SQL 99 compliant way of doing this)
    ;WITH Recurse(RootId, ParentID, FreeText, Level) AS
    (SELECT td.RootID, td.ParentID, '' as FreeText, 1 as Level
    from TEST_DATA td
    where rootid = 444
    union all
    select Recurse.RootID, td2.ParentId, td2.freetext + '-' + recurse.freetext, recurse.level+1 as level
    from TEST_DATA td2
    select * from Recurse;
    The problem: is to generating the freetext component correctly with oracle.
    Can generate the freetext component the wrong way round using SYS_CONNECT_BY_PATH.
    select connect_by_root(td.RootID), td.ParentID,
         CASE when level = 1 then ''
         ELSE
              SYS_CONNECT_BY_PATH(td.freetext, '-')
         END as FreeText, level
    from test_data td
    connect by td.RootID = prior td.ParentID
    which gives:
    RootID ParentID FreeText          LEVEL (Nesting)
    444 | 555     | |     1
    444 | 666 | ABC1 |          2
    444 | 777 | ABC1-DEF2 | 3
    444 | 888 | ABC1-DEF2-GHI3 | 4
    444 | 0 | ABC1-DEF2-GHI3-JKL4 | 5
    The problem is the freetext component is the wrong way round (the root node information always comes first).
    Tried looking at running something like:
    select connect_by_root(td.RootID), td.ParentID,
         CASE when level = 1 then ''
         ELSE
              td.freetext || '-' || FreeText2
         END as FreeText2, level
    from test_data td
    connect by td.RootID = prior td.ParentID
    --> but unfortunatly the aliasing of the column cannot be used to perform this operation [cannot reference the aliased column FreeText2].
    Is there a sys_connect_by_path_node? (The opposite of sys_connect_by_path)
    Returns the path of a column value from node to root,
    with column values separated by char for each row returned by CONNECT BY condition
    Or another way to get to the output required?
    Best Regards,
    D

    Not directly but there is a fairly common workaround using the undocumented REVERSE function.
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> SELECT SYS_CONNECT_BY_PATH (ename, '/') enames,
      2         REVERSE (SYS_CONNECT_BY_PATH (REVERSE (ename), '/')) reverse_enames
      3  FROM   emps
      4  START WITH mgr IS NULL
      5  CONNECT BY PRIOR empno = mgr;
    ENAMES                         REVERSE_ENAMES
    /KING                          KING/
    /KING/JONES                    JONES/KING/
    /KING/JONES/SCOTT              SCOTT/JONES/KING/
    /KING/JONES/SCOTT/ADAMS        ADAMS/SCOTT/JONES/KING/
    /KING/JONES/FORD               FORD/JONES/KING/
    /KING/JONES/FORD/SMITH         SMITH/FORD/JONES/KING/
    /KING/BLAKE                    BLAKE/KING/
    /KING/BLAKE/ALLEN              ALLEN/BLAKE/KING/
    /KING/BLAKE/WARD               WARD/BLAKE/KING/
    /KING/BLAKE/MARTIN             MARTIN/BLAKE/KING/
    /KING/BLAKE/TURNER             TURNER/BLAKE/KING/
    /KING/BLAKE/JAMES              JAMES/BLAKE/KING/
    /KING/CLARK                    CLARK/KING/
    /KING/CLARK/MILLER             MILLER/CLARK/KING/
    14 rows selected.
    SQL>

Maybe you are looking for