Traditional Joins vs ANSI Joins

Hi all, I come from a SQL Server background and relatively new to Oracle and I am trying to optimize the query below possibly using CTAS, eliminating the UNION ALL and also looking at changing the traditional Joins to ANSI: Ultimately I am interested in any tricks that can improve the performance of this query.
SELECT UPPER(LE.le_desc) le_desc, 1 rpt, 1 algnt, 'ADJUSTMENTS' AS rpt_typ, NULL AS uche, NULL AS uche_acct_no, NULL AS account, NULL AS description, NULL AS allocation_grp, NULL AS legal_structure, NULL AS income_bucket, NULL AS currency, NULL AS sp_investment, NULL AS amount, NULL AS allc_grp_id , ALC.allctn_id AS allctn_id, LE.le_cid,
DECODE (
SELECT lookup_data_mgmt.lookup_value FROM lookup_data_mgmt WHERE LE.mf_cde = lookup_data_mgmt.lookup_id),'Master',1,2
     ) m_f_ord FROM allctn ALC,
allctn_ds ADS,
allctn_gl_adj AGA,
allctn_gl_adj_dtl AGAD,
uche_acct CLA,
allctn_grp_acct AGAC,
ibg IBG,
ib IB,
allctn_grp AG,
allctr ALR,
allctr_le ALE,
le LE,
ls_flag,
curr CU,
ACCTNG_DS_uche_ACCT_GL ACCT_GL
WHERE
ALR.allctr_id = ALE.allctr_id AND
LE.le_cid = ALE.le_cid AND
ACCT_GL.ALLCTN_DS_ID = ads.allctn_ds_id AND ACCT_GL.ALLCTN_GRP_ACCT_ID = AGAC.ALLCTN_GRP_ACCT_ID AND LE.le_cid = ls_flag.le_cid AND ALR.allctr_id = ALC.allctr_id AND ALC.allctn_id = ADS.allctn_id AND ale.ALLCTR_LE_ID = ads.allctr_le_id AND AGA.allctn_ds_id = ADS.allctn_ds_id AND AGA.allctn_grp_id = AG.allctn_grp_id AND AGAD.allctn_gl_adj_id = AGA.allctn_gl_adj_id AND CLA.uche_acct_id = AGAD.uche_acct_id AND AGAC.uche_acct_id = CLA.uche_acct_id AND AG.allctn_grp_id = AGAC.allctn_grp_id AND IBG.ib_cid = IB.ib_cid AND IBG.ls_flag_id = ls_flag.ls_flag_id AND IBG.ibg_id = AG.ibg_id AND IBG.SUB_FLAG_HDG_CURR_ID = cu.curr_id (+)
GROUP BY
ALC.allctn_id,LE.le_cid,LE.le_desc,LE.mf_cde
UNION ALL
SELECT UPPER(LE.le_desc) le_desc, 2 rpt, 1 algnt, 'ADJUSTMENTS' AS rpt_typ, AGAD.uche_acct_id AS uche, CLA.acct_num AS uche_acct_no,
CASE WHEN CLA.uche_acct_id IN (SELECT AXA.uche_acct_id FROM ax_acct AXA) THEN (SELECT ax_acct_num FROM ax_acct WHERE AX_ACCT.uche_acct_id = CLA.uche_acct_id ) WHEN CLA.uche_acct_id IN (SELECT NERA.uche_acct_id FROM eph_nrstrcd_acct NERA) THEN (SELECT eph_acct_num FROM eph_nrstrcd_acct WHERE EPH_NRSTRCD_ACCT.uche_acct_id = CLA.uche_acct_id) WHEN CLA.uche_acct_id IN (SELECT EPH_RSTRCD_ACCT.uche_acct_id FROM eph_rstrcd_acct) THEN (SELECT EPH_RSTRCD_ACCT.eph_rstrcd_acct_num FROM eph_rstrcd_acct WHERE EPH_RSTRCD_ACCT.uche_acct_id = CLA.uche_acct_id ) END account, CLA.uche_acct_desc description, AG.allctn_grp_desc AS allocation_grp, ls_flag.ls_flag_name AS legal_structure, IB.ib_flag AS income_bucket, NULL AS currency, DECODE(IB.ib_flag,'SP ',(SELECT IBG.sub_flag_sp FROM ibg ibg1 WHERE ibg1.ibg_id = IBG.ibg_id AND IB.ib_cid = IBG.ib_cid),NULL) AS sp_investment, AGAD.adj_amt_in_base AS amount, AG.allctn_grp_id AS allc_grp_id , ALC.allctn_id AS allctn_id, LE.le_cid, DECODE ((SELECT lookup_data_mgmt.lookup_value FROM lookup_data_mgmt WHERE LE.mf_cde = lookup_data_mgmt.lookup_id),'Master',1,2) m_f_ord FROM allctn ALC, allctn_ds ADS, allctn_gl_adj AGA, allctn_gl_adj_dtl AGAD, uche_acct CLA, allctn_grp_acct AGAC, ibg IBG, ib IB, allctn_grp AG, allctr ALR, allctr_le ALE, le LE, ls_flag, curr CU, ACCTNG_DS_uche_ACCT_GL ACCT_GL WHERE ALR.allctr_id = ALE.allctr_id AND LE.le_cid = ALE.le_cid AND ACCT_GL.ALLCTN_DS_ID = ads.allctn_ds_id AND ACCT_GL.ALLCTN_GRP_ACCT_ID = AGAC.ALLCTN_GRP_ACCT_ID AND LE.le_cid = ls_flag.le_cid AND ALR.allctr_id = ALC.allctr_id AND ALC.allctn_id = ADS.allctn_id AND ale.ALLCTR_LE_ID = ads.allctr_le_id AND AGA.allctn_ds_id = ADS.allctn_ds_id AND AGA.allctn_grp_id = AG.allctn_grp_id AND AGAD.allctn_gl_adj_id = AGA.allctn_gl_adj_id AND CLA.uche_acct_id = AGAD.uche_acct_id AND AGAC.uche_acct_id = CLA.uche_acct_id AND AG.allctn_grp_id = AGAC.allctn_grp_id AND IBG.ib_cid = IB.ib_cid AND IBG.ls_flag_id = ls_flag.ls_flag_id AND IBG.ibg_id = AG.ibg_id AND AGAD.adj_amt_in_base <> 0 AND IBG.SUB_FLAG_HDG_CURR_ID = cu.curr_id (+)
Any help will be greatly appreciated...
Thanks

1) Can you edit your post to put [pr[/b][b]e] and [pr[/b][b]e] tags around the code to preserve white space?
2) From a performance perspective, there should be no difference between traditional and ANSI joins (unless, of course, you're on an older version of Oracle that doesn't support ANSI joins).
3) What is the query plan?
4) What is the Oracle version?
5) Are your statistics accurate?
Justin

Similar Messages

  • Query Rewrite ISSUE (ANSI JOINS do not work, traditional join works ) 11gR2

    For some types of queries constructed with ANSI JOINS, materialized views are not being used.
    This is currently increasing time on various reports since we cannot control the way the queries are generated(Tableau Application generates and runs queries against the STAR Schema).
    Have tried to debug this behavior using DBMS_MVIEW.EXPLAIN_REWRITE and mv_capabilities function without any success.
    The database is configured for query rewrite: REWRITE INTEGRITY, QUERY REWRITE ENABLED and other settings are in place.
    Have successfully reproduced the issue using SH Sample schema:
    Q1 and Q2 are logically identical the only difference between them being the type of join used:
    Q1: ANSI JOIN
    Q2: Traditional join
    Below is an example that can be validated on SH sample schema.
    Any help on this will be highly appreciated.
    -- Q1: the query is generated by an app and needs to be rewritten with materialized view
    SELECT cntr.country_subregion, cust.cust_year_of_birth, COUNT(DISTINCT cust.cust_first_name)
    FROM customers cust
    INNER JOIN countries cntr
       ON cust.country_id = cntr.country_id
    GROUP BY cntr.country_subregion, cust_year_of_birth;
    -- Q2: the query with traditional join is rewritten with materialized view
    SELECT cntr.country_subregion, cust.cust_year_of_birth, COUNT(DISTINCT cust.cust_first_name)
    FROM customers cust
    INNER JOIN countries cntr
       ON cust.country_id = cntr.country_id
    GROUP BY cntr.country_subregion, cust_year_of_birth;Tested both queries with the following materialized views:
    CREATE MATERIALIZED VIEW MVIEW_TEST_1
    ENABLE QUERY REWRITE
    AS
    SELECT cntr.country_subregion, cust.cust_year_of_birth, COUNT(DISTINCT cust.cust_first_name)
    FROM customers cust
    INNER JOIN countries cntr
       ON cust.country_id = cntr.country_id
    GROUP BY cntr.country_subregion, cust_year_of_birth;
    CREATE MATERIALIZED VIEW MVIEW_TEST_2
    ENABLE QUERY REWRITE
    AS
    SELECT cntr.country_subregion, cust.cust_year_of_birth, COUNT(DISTINCT cust.cust_first_name)
    FROM customers cust,  countries cntr
    WHERE cust.country_id = cntr.country_id
    GROUP BY cntr.country_subregion, cust_year_of_birth;Explain Plans showing that Q1 does not use materialized view and Q2 uses materialized view
    SET AUTOTRACE TRACEONLY
    --Q1 does not use MVIEW_TEST_1
    SQL> SELECT cntr.country_subregion, cust.cust_year_of_birth, COUNT(DISTINCT cust.cust_first_name)
    FROM customers cust
    INNER JOIN countries cntr
       ON cust.country_id = cntr.country_id
    GROUP BY cntr.country_subregion, cust_year_of_birth;  2    3    4    5 
    511 rows selected.
    Execution Plan
    Plan hash value: 1218164197
    | Id  | Operation           | Name       | Rows  | Bytes |TempSpc| Cost (%CPU)| Time       |
    |   0 | SELECT STATEMENT      |        |   425 | 12325 |       |   916   (1)| 00:00:11 |
    |   1 |  HASH GROUP BY           |        |   425 | 12325 |       |   916   (1)| 00:00:11 |
    |   2 |   VIEW                | VM_NWVW_1 | 55500 |  1571K|       |   916   (1)| 00:00:11 |
    |   3 |    HASH GROUP BY      |        | 55500 |  1842K|  2408K|   916   (1)| 00:00:11 |
    |*  4 |     HASH JOIN           |        | 55500 |  1842K|       |   409   (1)| 00:00:05 |
    |   5 |      TABLE ACCESS FULL| COUNTRIES |    23 |   414 |       |     3   (0)| 00:00:01 |
    |   6 |      TABLE ACCESS FULL| CUSTOMERS | 55500 |   867K|       |   405   (1)| 00:00:05 |
    --Q2 uses MVIEW_TEST_2
    SQL> SELECT cntr.country_subregion, cust.cust_year_of_birth, COUNT(DISTINCT cust.cust_first_name)
    FROM customers cust,  countries cntr
    WHERE cust.country_id = cntr.country_id
    GROUP BY cntr.country_subregion, cust_year_of_birth;  2    3    4 
    511 rows selected.
    Execution Plan
    Plan hash value: 2126022771
    | Id  | Operation               | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT          |              |     511 | 21973 |       3   (0)| 00:00:01 |
    |   1 |  MAT_VIEW REWRITE ACCESS FULL| MVIEW_TEST_2 |     511 | 21973 |       3   (0)| 00:00:01 |
    ---------------------------------------------------------------------------------------------Database version 11gR1 (Tested also on 11gR2)
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit 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

    Thanks for the formatting tips.
    Just found an Oracle Bug which explains the above behavior.
    Unfortunately the bug will be fixed only in 12.1 Release so as a workaround will try to use traditional joins.
    For those who have metalink access see [Bug 10145667 : ERRORS TRYING TO REWRITE QUERY WITH EXACT TEXT MATCH TO MVIEW]

  • ANSI to traditional (+) join syntax

    Hi All,
    Can anyone pl help me to understand how the diff tables in this tables are joined ( even 1 join would help) as I am not able to differentiate where the first join ended and whether the result is attched to the previous one or what all :(
    I am little confused about how to convert this query in ANSI to the traditional (+) sysntax as I am not able to understannd which table is joined to which table and where exactly the previous join ends.
    select distinct a.instrument_id       "INSTRUMENT ID",
                    a.name                "DESCRIPTION",
                    a.DEBT_PRIORITY_CLASS "DEBT PRIORITY CLASS",
                    c.alias               "ISIN",
                    b.alias               "MDSCURVE"
      from (select distinct i.instrument_id,
                            i.name,
                            case
                              when (mn2.display_name != 'DEBT PRIORITY CLASS' and
                                   mn2.display_name is not null) then
                               mn2.display_name
                              else
                               mn1.display_name
                            end "DEBT_PRIORITY_CLASS"
              from instrument i, inst_debt id
              left join marsnode mn1 on (id.debt_priority_class_id = mn1.node_id and
                                        mn1.close_date is null and
                                        mn1.type_id = 58412926883279)
              left join marsnodelink mnl1 on (mn1.node_id = mnl1.node_id and
                                             mnl1.close_date is null and
                                             mnl1.begin_cob_date <=
                                             TO_DATE('27-Oct-2010',
                                                      'DD-Mon-YYYY') and
                                             mnl1.end_cob_date >
                                             TO_DATE('27-Oct-2010',
                                                      'DD-Mon-YYYY'))
              left join marsnode mn2 on (mnl1.parent_id = mn2.node_id and
                                        mn2.close_date is null and
                                        mn2.type_id = 58412926883279)
             where i.instrument_id = id.instrument_id
               and i.end_cob_date > TO_DATE('27-Oct-2010', 'DD-Mon-YYYY')
               and i.close_action_id is null
               and i.product_sub_type_id = 3
               and i.begin_cob_date <= TO_DATE('27-Oct-2010', 'DD-Mon-YYYY')
               and i.instrument_vn = id.instrument_vn) a
      left outer join (select i.instrument_id, ia.alias as alias
                         from instrument i, inst_alias ia, domain d
                        where i.instrument_id = ia.instrument_id
                          and ia.domain_id = d.domain_id
                          and d.name = 'MDSCURVE'
                          and i.close_action_id is null
                          and i.product_sub_type_id = 3
                          and i.begin_cob_date <=
                              TO_DATE('27-Oct-2010', 'DD-Mon-YYYY')
                          and i.end_cob_date >
                              TO_DATE('27-Oct-2010', 'DD-Mon-YYYY')) b on (a.instrument_id =
                                                                          b.instrument_id)
      left outer join (select i.instrument_id, ia.alias as alias
                         from instrument i, inst_alias ia, domain d
                        where i.instrument_id = ia.instrument_id
                          and ia.domain_id = d.domain_id
                          and d.name = 'ISIN'
                          and i.close_action_id is null
                          and i.product_sub_type_id = 3
                          and i.begin_cob_date <=
                              TO_DATE('27-Oct-2010', 'DD-Mon-YYYY')
                          and i.end_cob_date >
                              TO_DATE('27-Oct-2010', 'DD-Mon-YYYY')) c on (a.instrument_id =  c.instrument_id)Specialy the problem with the first left outer join (from instrument i, inst_debt id) , there are many outer joins and i am not able to understand this thing.
    Please help me to understand this thing.
    Rgds,
    Aashish

    maybe the comments in this will help...
    SELECT   DISTINCT a.instrument_id "INSTRUMENT ID",
                      a.name "DESCRIPTION",
                      a.DEBT_PRIORITY_CLASS "DEBT PRIORITY CLASS",
                      c.alias "ISIN",
                      b.alias "MDSCURVE"
      FROM         (SELECT   DISTINCT
                             i.instrument_id,
                             i.name,
                             CASE
                                WHEN (mn2.display_name != 'DEBT PRIORITY CLASS'
                                      AND mn2.display_name IS NOT NULL)
                                THEN
                                   mn2.display_name
                                ELSE
                                   mn1.display_name
                             END
                                "DEBT_PRIORITY_CLASS"
                      FROM   instrument i,
                                      inst_debt id
                                   LEFT JOIN
                                      marsnode mn1 -- LEFT JOIN from inst_debt to marsnode
                                   ON (id.debt_priority_class_id = mn1.node_id
                                       AND mn1.close_date IS NULL
                                       AND mn1.type_id = 58412926883279)
                                LEFT JOIN  -- LEFT JOIN from marsnode to marsnodelink
                                   marsnodelink mnl1
                                ON (mn1.node_id = mnl1.node_id
                                    AND mnl1.close_date IS NULL
                                    AND mnl1.begin_cob_date <=
                                          TO_DATE ('27-Oct-2010', 'DD-Mon-YYYY')
                                    AND mnl1.end_cob_date >
                                          TO_DATE ('27-Oct-2010', 'DD-Mon-YYYY'))
                             LEFT JOIN
                                marsnode mn2 -- LEFT JOIN from marsnodelink to marsnode
                             ON (    mnl1.parent_id = mn2.node_id
                                 AND mn2.close_date IS NULL
                                 AND mn2.type_id = 58412926883279)
                     WHERE   i.instrument_id = id.instrument_id
                             AND i.end_cob_date >
                                   TO_DATE ('27-Oct-2010', 'DD-Mon-YYYY')
                             AND i.close_action_id IS NULL
                             AND i.product_sub_type_id = 3
                             AND i.begin_cob_date <=
                                   TO_DATE ('27-Oct-2010', 'DD-Mon-YYYY')
                             AND i.instrument_vn = id.instrument_vn) a -- End of in-line view 'a'
                LEFT OUTER JOIN -- LEFT OUTER JOIN from in-line view 'a' to inline view 'b'
                   (SELECT   i.instrument_id, ia.alias AS alias
                      FROM   instrument i, inst_alias ia, domain d
                     WHERE       i.instrument_id = ia.instrument_id
                             AND ia.domain_id = d.domain_id
                             AND d.name = 'MDSCURVE'
                             AND i.close_action_id IS NULL
                             AND i.product_sub_type_id = 3
                             AND i.begin_cob_date <=
                                   TO_DATE ('27-Oct-2010', 'DD-Mon-YYYY')
                             AND i.end_cob_date >
                                   TO_DATE ('27-Oct-2010', 'DD-Mon-YYYY')) b -- End of inline view 'b'
                ON (a.instrument_id = b.instrument_id)
             LEFT OUTER JOIN --LEFT OUTER JOIN from inline view 'a' to inline view 'c'
                (SELECT   i.instrument_id, ia.alias AS alias
                   FROM   instrument i, inst_alias ia, domain d
                  WHERE       i.instrument_id = ia.instrument_id
                          AND ia.domain_id = d.domain_id
                          AND d.name = 'ISIN'
                          AND i.close_action_id IS NULL
                          AND i.product_sub_type_id = 3
                          AND i.begin_cob_date <=
                                TO_DATE ('27-Oct-2010', 'DD-Mon-YYYY')
                          AND i.end_cob_date >
                                TO_DATE ('27-Oct-2010', 'DD-Mon-YYYY')) c --End of inline view 'c'
             ON (a.instrument_id = c.instrument_id)?
    Cheers
    Ben

  • Needed help to improve the performance of a select query?

    Hi,
    I have been preparing a report which involves data to be fetched from 4 to 5 different tables and calculation has to performed on some columns also,
    i planned to write a single cursor to populate 1 temp table.i have used INLINE VIEW,EXISTS more frequently in the select query..please go through the query and suggest me a better way to restructure the query.
    cursor c_acc_pickup_incr(p_branch_code varchar2, p_applDate date, p_st_dt date, p_ed_dt date) is
    select sca.branch_code "BRANCH",
    sca.cust_ac_no "ACCOUNT",
    to_char(p_applDate, 'YYYYMM') "YEARMONTH",
    sca.ccy "CURRENCY",
    sca.account_class "PRODUCT",
    sca.cust_no "CUSTOMER",
    sca.ac_desc "DESCRIPTION",
    null "LOW_BAL",
    null "HIGH_BAL",
    null "AVG_CR_BAL",
    null "AVG_DR_BAL",
    null "CR_DAYS",
    null "DR_DAYS",
    --null                                 "CR_TURNOVER",       
    --null                                 "DR_TURNOVER",       
    null "DR_OD_DAYS",
    (select sum(gf.limit_amount * (scal.linkage_percentage / 100)) +
    (case when (p_applDate >= sca.tod_limit_start_date and
    p_applDate <= nvl(sca.tod_limit_end_date, p_applDate)) then
    sca.tod_limit else 0 end) dd
    from getm_facility gf, sttm_cust_account_linkages scal
    where gf.line_code || gf.line_serial = scal.linked_ref_no
    and cust_ac_no = sca.cust_ac_no) "OD_LIMIT",
    --sc.credit_rating                      "CR_GRADE",        
    null "AVG_NET_BAL",
    null "UNAUTH_OD_AMT",
    sca.acy_blocked_amount "AMT_BLOCKED",
    (select sum(amt)
    from ictb_entries_history ieh
    where ieh.acc = sca.cust_ac_no
    and ieh.brn = sca.branch_code
    and ieh.drcr = 'D'
    and ieh.liqn = 'Y'
    and ieh.entry_passed = 'Y'
    and ieh.ent_dt between p_st_dt and p_ed_dt
    and exists (
    select * from ictm_pr_int ipi, ictm_rule_frm irf
    where ipi.product_code = ieh.prod
    and ipi.rule = irf.rule_id
    and irf.book_flag = 'B')) "DR_INTEREST",
    (select sum(amt)
    from ictb_entries_history ieh
    where ieh.acc = sca.cust_ac_no
    and ieh.brn = sca.branch_code
    and ieh.drcr = 'C'
    and ieh.liqn = 'Y'
    and ieh.entry_passed = 'Y'
    and ieh.ent_dt between p_st_dt and p_ed_dt
    and exists (
    select * from ictm_pr_int ipi, ictm_rule_frm irf
    where ipi.product_code = ieh.prod
    and ipi.rule = irf.rule_id
    and irf.book_flag = 'B')) "CR_INTEREST",
    (select sum(amt) from ictb_entries_history ieh
    where ieh.brn = sca.branch_code
    and ieh.acc = sca.cust_ac_no
    and ieh.ent_dt between p_st_dt and p_ed_dt
    and exists (
    select product_code
    from ictm_product_definition ipd
    where ipd.product_code = ieh.prod
    and ipd.product_type = 'C')) "FEE_INCOME",
    sca.record_stat "ACC_STATUS",
    case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
    and not exists (select 1
    from ictm_tdpayin_details itd
    where itd.multimode_payopt = 'Y'
    and itd.brn = sca.branch_code
    and itd.acc = sca.cust_ac_no
    and itd.multimode_offset_brn is not null
    and itd.multimode_tdoffset_acc is not null))
    then 1 else 0 end "NEW_ACC_FOR_THE_MONTH",
    case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
    and trunc(sc.cif_creation_date,'MM') = trunc(p_applDate,'MM')
    and not exists (select 1
    from ictm_tdpayin_details itd
    where itd.multimode_payopt = 'Y'
    and itd.brn = sca.branch_code
    and itd.acc = sca.cust_ac_no
    and itd.multimode_offset_brn is not null
    and itd.multimode_tdoffset_acc is not null))
    then 1 else 0 end "NEW_ACC_FOR_NEW_CUST",
    (select 1 from dual
    where exists (select 1 from ictm_td_closure_renew itcr
    where itcr.brn = sca.branch_code
    and itcr.acc = sca.cust_ac_no
    and itcr.renewal_date = sysdate)
    or exists (select 1 from ictm_tdpayin_details itd
    where itd.multimode_payopt = 'Y'
    and itd.brn = sca.branch_code
    and itd.acc = sca.cust_ac_no
    and itd.multimode_offset_brn is not null
    and itd.multimode_tdoffset_acc is not null)) "RENEWED_OR_ROLLOVER",
    (select maturity_date from ictm_acc ia
    where ia.brn = sca.branch_code
    and ia.acc = sca.cust_ac_no) "MATURITY_DATE",
    sca.ac_stat_no_dr "DR_DISALLOWED",
    sca.ac_stat_no_cr "CR_DISALLOWED",
    sca.ac_stat_block                     "BLOCKED_ACC",       Not Reqd
    sca.ac_stat_dormant "DORMANT_ACC",
    sca.ac_stat_stop_pay "STOP_PAY_ACC", --New
    sca.ac_stat_frozen "FROZEN_ACC",
    sca.ac_open_date "ACC_OPENING_DT",
    sca.address1 "ADD_LINE_1",
    sca.address2 "ADD_LINE_2",
    sca.address3 "ADD_LINE_3",
    sca.address4 "ADD_LINE_4",
    sca.joint_ac_indicator "JOINT_ACC",
    sca.acy_avl_bal "CR_BAL",
    0 "DR_BAL",
    0 "CR_BAL_LCY", t
    0 "DR_BAL_LCY",
    null "YTD_CR_MOVEMENT",
    null "YTD_DR_MOVEMENT",
    null "YTD_CR_MOVEMENT_LCY",
    null "YTD_DR_MOVEMENT_LCY",
    null "MTD_CR_MOVEMENT",
    null "MTD_DR_MOVEMENT",
    null "MTD_CR_MOVEMENT_LCY",
    null "MTD_DR_MOVEMENT_LCY",
    'N' "BRANCH_TRFR", --New
    sca.provision_amount "PROVISION_AMT",
    sca.account_type "ACCOUNT_TYPE",
    nvl(sca.tod_limit, 0) "TOD_LIMIT",
    nvl(sca.sublimit, 0) "SUB_LIMIT",
    nvl(sca.tod_limit_start_date, global.min_date) "TOD_START_DATE",
    nvl(sca.tod_limit_end_date, global.max_date) "TOD_END_DATE"
    from sttm_cust_account sca, sttm_customer sc
    where sca.branch_code = p_branch_code
    and sca.cust_no = sc.customer_no
    and ( exists (select 1 from actb_daily_log adl
    where adl.ac_no = sca.cust_ac_no
    and adl.ac_branch = sca.branch_code
    and adl.trn_dt = p_applDate
    and adl.auth_stat = 'A')
    or exists (select 1 from catm_amount_blocks cab
    where cab.account = sca.cust_ac_no
    and cab.branch = sca.branch_code
    and cab.effective_date = p_applDate
    and cab.auth_stat = 'A')
    or exists (select 1 from ictm_td_closure_renew itcr
    where itcr.acc = sca.cust_ac_no
    and itcr.brn = sca.branch_code
    and itcr.renewal_date = p_applDate)
    or exists (select 1 from sttm_ac_stat_change sasc
    where sasc.cust_ac_no = sca.cust_ac_no
    and sasc.branch_code = sca.branch_code
    and sasc.status_change_date = p_applDate
    and sasc.auth_stat = 'A')
    or exists (select 1 from cstb_acc_brn_trfr_log cabtl
    where cabtl.branch_code = sca.branch_code
    and cabtl.cust_ac_no = sca.cust_ac_no
    and cabtl.process_status = 'S'
    and cabtl.process_date = p_applDate)
    or exists (select 1 from sttbs_provision_history sph
    where sph.branch_code = sca.branch_code
    and sph.cust_ac_no = sca.cust_ac_no
    and sph.esn_date = p_applDate)
    or exists (select 1 from sttms_cust_account_dormancy scad
    where scad.branch_code = sca.branch_code
    and scad.cust_ac_no = sca.cust_ac_no
    and scad.dormancy_start_dt = p_applDate)
    or sca.maker_dt_stamp = p_applDate
    or sca.status_since = p_applDate
    l_tb_acc_det ty_tb_acc_det_int;
    l_brnrec cvpks_utils.rec_brnlcy;
    l_acbr_lcy sttms_branch.branch_lcy%type;
    l_lcy_amount actbs_daily_log.lcy_amount%type;
    l_xrate number;
    l_dt_rec sttm_dates%rowtype;
    l_acc_rec sttm_cust_account%rowtype;
    l_acc_stat_row ty_r_acc_stat;
    Edited by: user13710379 on Jan 7, 2012 12:18 AM

    I see it more like shown below (possibly with no inline selects
    Try to get rid of the remaining inline selects ( left as an exercise ;) )
    and rewrite traditional joins as ansi joins as problems might arise using mixed syntax as I have to leave so I don't have time to complete the query
    select sca.branch_code "BRANCH",
           sca.cust_ac_no "ACCOUNT",
           to_char(p_applDate, 'YYYYMM') "YEARMONTH",
           sca.ccy "CURRENCY",
           sca.account_class "PRODUCT",
           sca.cust_no "CUSTOMER",
           sca.ac_desc "DESCRIPTION",
           null "LOW_BAL",
           null "HIGH_BAL",
           null "AVG_CR_BAL",
           null "AVG_DR_BAL",
           null "CR_DAYS",
           null "DR_DAYS",
    --     null "CR_TURNOVER",
    --     null "DR_TURNOVER",
           null "DR_OD_DAYS",
           w.dd "OD_LIMIT",
    --     sc.credit_rating "CR_GRADE",
           null "AVG_NET_BAL",
           null "UNAUTH_OD_AMT",
           sca.acy_blocked_amount "AMT_BLOCKED",
           x.dr_int "DR_INTEREST",
           x.cr_int "CR_INTEREST",
           y.fee_amt "FEE_INCOME",
           sca.record_stat "ACC_STATUS",
           case when trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
                 and not exists(select 1
                                  from ictm_tdpayin_details itd
                                 where itd.multimode_payopt = 'Y'
                                   and itd.brn = sca.branch_code
                                   and itd.acc = sca.cust_ac_no
                                   and itd.multimode_offset_brn is not null
                                   and itd.multimode_tdoffset_acc is not null
                then 1
                else 0
           end "NEW_ACC_FOR_THE_MONTH",
           case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
                 and trunc(sc.cif_creation_date,'MM') = trunc(p_applDate,'MM')
                 and not exists(select 1
                                  from ictm_tdpayin_details itd
                                 where itd.multimode_payopt = 'Y'
                                   and itd.brn = sca.branch_code
                                   and itd.acc = sca.cust_ac_no
                                   and itd.multimode_offset_brn is not null
                                   and itd.multimode_tdoffset_acc is not null
                then 1
                else 0
           end "NEW_ACC_FOR_NEW_CUST",
           (select 1 from dual
             where exists(select 1
                            from ictm_td_closure_renew itcr
                           where itcr.brn = sca.branch_code
                             and itcr.acc = sca.cust_ac_no
                             and itcr.renewal_date = sysdate
                or exists(select 1
                            from ictm_tdpayin_details itd
                           where itd.multimode_payopt = 'Y'
                             and itd.brn = sca.branch_code
                             and itd.acc = sca.cust_ac_no
                             and itd.multimode_offset_brn is not null
                             and itd.multimode_tdoffset_acc is not null
           ) "RENEWED_OR_ROLLOVER",
           m.maturity_date "MATURITY_DATE",
           sca.ac_stat_no_dr "DR_DISALLOWED",
           sca.ac_stat_no_cr "CR_DISALLOWED",
    --     sca.ac_stat_block "BLOCKED_ACC", --Not Reqd
           sca.ac_stat_dormant "DORMANT_ACC",
           sca.ac_stat_stop_pay "STOP_PAY_ACC", --New
           sca.ac_stat_frozen "FROZEN_ACC",
           sca.ac_open_date "ACC_OPENING_DT",
           sca.address1 "ADD_LINE_1",
           sca.address2 "ADD_LINE_2",
           sca.address3 "ADD_LINE_3",
           sca.address4 "ADD_LINE_4",
           sca.joint_ac_indicator "JOINT_ACC",
           sca.acy_avl_bal "CR_BAL",
           0 "DR_BAL",
           0 "CR_BAL_LCY", t
           0 "DR_BAL_LCY",
           null "YTD_CR_MOVEMENT",
           null "YTD_DR_MOVEMENT",
           null "YTD_CR_MOVEMENT_LCY",
           null "YTD_DR_MOVEMENT_LCY",
           null "MTD_CR_MOVEMENT",
           null "MTD_DR_MOVEMENT",
           null "MTD_CR_MOVEMENT_LCY",
           null "MTD_DR_MOVEMENT_LCY",
           'N' "BRANCH_TRFR", --New
           sca.provision_amount "PROVISION_AMT",
           sca.account_type "ACCOUNT_TYPE",
           nvl(sca.tod_limit, 0) "TOD_LIMIT",
           nvl(sca.sublimit, 0) "SUB_LIMIT",
           nvl(sca.tod_limit_start_date, global.min_date) "TOD_START_DATE",
           nvl(sca.tod_limit_end_date, global.max_date) "TOD_END_DATE"
      from sttm_cust_account sca,
           sttm_customer sc,
           (select sca.cust_ac_no
                   sum(gf.limit_amount * (scal.linkage_percentage / 100)) +
                       case when p_applDate >= sca.tod_limit_start_date
                             and p_applDate <= nvl(sca.tod_limit_end_date, p_applDate)
                            then sca.tod_limit else 0
                       end
                      ) dd
              from sttm_cust_account sca
                   getm_facility gf,
                   sttm_cust_account_linkages scal
             where gf.line_code || gf.line_serial = scal.linked_ref_no
               and cust_ac_no = sca.cust_ac_no
             group by sca.cust_ac_no
           ) w,
           (select acc,
                   brn,
                   sum(decode(drcr,'D',amt)) dr_int,
                   sum(decode(drcr,'C',amt)) cr_int
              from ictb_entries_history ieh
             where ent_dt between p_st_dt and p_ed_dt
               and drcr in ('C','D')
               and liqn = 'Y'
               and entry_passed = 'Y'
               and exists(select null
                            from ictm_pr_int ipi,
                                 ictm_rule_frm irf
                           where ipi.rule = irf.rule_id
                             and ipi.product_code = ieh.prod 
                             and irf.book_flag = 'B'
             group by acc,brn
           ) x,
           (select acc,
                   brn,
                   sum(amt) fee_amt
              from ictb_entries_history ieh
             where ieh.ent_dt between p_st_dt and p_ed_dt
               and exists(select product_code
                            from ictm_product_definition ipd
                           where ipd.product_code = ieh.prod
                             and ipd.product_type = 'C'
             group by acc,brn
           ) y,
           ictm_acc m,
           (select sca.cust_ac_no,
                   sca.branch_code
                   coalesce(nvl2(coalesce(t1.ac_no,t1.ac_branch),'exists',null),
                            nvl2(coalesce(t2.account,t2.account),'exists',null),
                            nvl2(coalesce(t3.acc,t3.brn),'exists',null),
                            nvl2(coalesce(t4.cust_ac_no,t4.branch_code),'exists',null),
                            nvl2(coalesce(t5.cust_ac_no,t5.branch_code),'exists',null),
                            nvl2(coalesce(t6.cust_ac_no,t6.branch_code),'exists',null),
                            nvl2(coalesce(t7.cust_ac_no,t7.branch_code),'exists',null),
                            decode(sca.maker_dt_stamp,p_applDate,'exists'),
                            decode(sca.status_since,p_applDate,'exists')
                           ) existence
              from sttm_cust_account sca
                   left outer join
                   (select ac_no,ac_branch
                      from actb_daily_log
                     where trn_dt = p_applDate
                       and auth_stat = 'A'
                   ) t1
                on (sca.cust_ac_no = t1.ac_no
               and  sca.branch_code = t1.ac_branch
                   left outer join
                   (select account,account
                      from catm_amount_blocks
                     where effective_date = p_applDate
                       and auth_stat = 'A'
                   ) t2
                on (sca.cust_ac_no = t2.account
               and  sca.branch_code = t2.branch
                   left outer join
                   (select acc,brn
                      from ictm_td_closure_renew itcr
                     where renewal_date = p_applDate
                   ) t3
                on (sca.cust_ac_no = t3.acc
               and  sca.branch_code = t3.brn
                   left outer join
                   (select cust_ac_no,branch_code
                      from sttm_ac_stat_change
                     where status_change_date = p_applDate
                       and auth_stat = 'A'
                   ) t4
                on (sca.cust_ac_no = t4.cust_ac_no
               and  sca.branch_code = t4.branch_code
                   left outer join
                   (select cust_ac_no,branch_code
                      from cstb_acc_brn_trfr_log
                     where process_date = p_applDate
                       and process_status = 'S'
                   ) t5
                on (sca.cust_ac_no = t5.cust_ac_no
               and  sca.branch_code = t5.branch_code
                   left outer join
                   (select cust_ac_no,branch_code
                      from sttbs_provision_history
                     where esn_date = p_applDate
                   ) t6
                on (sca.cust_ac_no = t6.cust_ac_no
               and  sca.branch_code = t6.branch_code
                   left outer join
                   (select cust_ac_no,branch_code
                      from sttms_cust_account_dormancy
                     where dormancy_start_dt = p_applDate
                   ) t7
                on (sca.cust_ac_no = t7.cust_ac_no
               and  sca.branch_code = t7.branch_code
           ) z
    where sca.branch_code = p_branch_code
       and sca.cust_no = sc.customer_no
       and sca.cust_ac_no = w.cust_ac_no
       and sca.cust_ac_no = x.acc
       and sca.branch_code = x.brn
       and sca.cust_ac_no = y.acc
       and sca.branch_code = y.brn
       and sca.cust_ac_no = m.acc
       and sca.branch_code = m.brn
       and sca.cust_ac_no = z.sca.cust_ac_no
       and sca.branch_code = z.branch_code
       and z.existence is not nullRegards
    Etbin

  • Oracle 8.1 with tutorial

    Hi
    maybe this is a trivial question to answer:
    We are evaluating Kodo against another Vendor on Oracle 8.1.7. I am working
    my way through the tutorial and got stuck on the query
    java tutorial.AnimalMaintenance details Rabbit "eater.name == \"Sizzy\""
    This generates the following ORACLE error:
    Exception in thread "main" com.solarmetric.kodo.runtime.DataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExcept
    ionWrapper:
    [SQL=SELECT t0.JDOIDX, t0.JDOCLASSX, t0.JDOLOCKX, t0.NAMEX, t0.PRICEX,
    t0.EATERX, t0.ISDEADX, t0.ISFEMALEX FROM ANIMALX
    t0 INNER JOIN ANIMALX t1 ON t0.EATERX = t1.JDOIDX WHERE t1.NAMEX = 'Sizzy'
    AND t0.JDOCLASSX = 'tutorial.Rabbit']
    [PRE=SELECT t0.JDOIDX, t0.JDOCLASSX, t0.JDOLOCKX, t0.NAMEX, t0.PRICEX,
    t0.EATERX, t0.ISDEADX, t0.ISFEMALEX FROM ANIMALX
    t0 INNER JOIN ANIMALX t1 ON t0.EATERX = t1.JDOIDX WHERE t1.NAMEX = ? AND
    t0.JDOCLASSX = ?]
    ORA-00933: SQL command not properly ended
    [code=933;state=42000]
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    [SQL=SELECT t0.JDOIDX, t0.JDOCLASSX, t0.JDOLOCKX, t0.NAMEX, t0.PRICEX,
    t0.EATERX, t0.ISDEADX, t0.ISFEMALEX FROM ANIMALX
    t0 INNER JOIN ANIMALX t1 ON t0.EATERX = t1.JDOIDX WHERE t1.NAMEX = 'Sizzy'
    AND t0.JDOCLASSX = 'tutorial.Rabbit']
    [PRE=SELECT t0.JDOIDX, t0.JDOCLASSX, t0.JDOLOCKX, t0.NAMEX, t0.PRICEX,
    t0.EATERX, t0.ISDEADX, t0.ISFEMALEX FROM ANIMALX
    t0 INNER JOIN ANIMALX t1 ON t0.EATERX = t1.JDOIDX WHERE t1.NAMEX = ? AND
    t0.JDOCLASSX = ?]
    ORA-00933: SQL command not properly ended
    at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwDataStore(SQLExceptions.java:64)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCStoreManager.java:1111)
    at
    com.solarmetric.kodo.impl.jdbc.query.JDBCQuery.executeQuery(JDBCQuery.java:106)
    at
    com.solarmetric.kodo.query.QueryImpl$DatastoreQueryExecutor.executeQuery(QueryImpl.java:1554)
    at
    com.solarmetric.kodo.query.QueryImpl.executeQueryWithMap(QueryImpl.java:675)
    I admit my SQL and ORACLE knowledge is a bit rosty, so I looked it up and
    found that the JOIN syntax has only been introduced in ORACLE 9 SQL. Kodo
    claims to support ORACLE 8.1.
    Is there a switch to make Kodo use the old ORACLE JOIN syntax ( select *
    from table a1, a2 where a1.pk = a2.fk and ... instead of INNER JOIN )?
    Thank you for your help
    Sven Erik Knop
    Principal Consultant
    Versant
    email: [email protected]
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

    Ah, it's so nice to fine the answer here like this.Just so you know, in 2.5.2 we've added a "database" value option to the
    UseSQL92Joins property. This option uses DB-specific join syntax, if the
    DB has it... otherwise it reverts to SQL92. Using this option
    (which is now the default), Oracle would use traditional join syntax but
    would use the "(+)" modifier for outer join support too.

  • Help with ansi joins

    hi all
    i have this query in which i have used ansi joins,not an expert though on ansi joins ...got to knw abt ansi joins only today
    SELECT abc.vendor_number, abc.vendor_name, api.invoice_amount,
           api.invoice_date, api.invoice_type_lookup_code, api.invoice_num,
           avp.prepay_number, api.description,   --,avp.INVOICE_CURRENCY_CODE CCY,
                                              aup.prepay_amount_applied,
           aup.prepay_amount_remaining,
           SUM (-avp.prepay_amount_remaining * NVL (api.exchange_rate, 1)
               ) prepaid_available,
           '1234' voucher_number
      FROM ap_invoices_v api INNER JOIN ap_invoice_distributions_v aid ON (    api.invoice_id =
                                                                                  aid.invoice_id
                                                                           AND api.invoice_type_lookup_code =
                                                                                  'PREPAYMENT'
                                                                           AND api.invoice_num =
                                                                                  '5'
                                                                          ), ap_invoices_v api LEFT OUTER JOIN ap_apply_prepays_v avp ON (api.invoice_id =
                                                                                                                                             avp.invoice_id
           ap_invoices_v api INNER JOIN ap_checks_v abc ON (abc.vendor_id =
                                                                     api.vendor_id
                                                           ), ap_invoice_payments abb LEFT OUTER JOIN ap_apply_prepays_v avp ON (abb.invoice_id =
                                                                                                                                    avp.invoice_id
           ap_invoice_distributions_v aid LEFT OUTER JOIN ap_unapply_prepays_v aup ON (aid.invoice_distribution_id =
                                                                                          aup.prepay_distribution_id
           ap_unapply_prepays_v aup LEFT OUTER JOIN ap_apply_prepays_v avp ON (aup.prepay_distribution_id =
                                                                                  avp.invoice_distribution_id
                                                                              ), ap_invoices_v api INNER JOIN ap_invoice_payments abb ON (abb.invoice_id =
                                                                                                                                         api.invoice_id
                                                                                                                                     )i am getting column ambigously
    defined in the select clause,is there another way to refer to the columns?
    kindly guide
    thanking in advance
    Edited by: makdutakdu on Dec 20, 2011 11:28 AM

    what is it?
    ap_invoices_v api INNER JOIN ap_invoice_distributions_v aid ON (    api.invoice_id =
                                                                                  aid.invoice_id
                                                                           AND api.invoice_type_lookup_code =
                                                                                  'PREPAYMENT'
                                                                           AND api.invoice_num =
                                                                                  '5'
                                                                          ), ap_invoices_v api LEFT OUTER JOIN ap_apply_prepays_v avp ON (api.invoice_id =
                                                                                                                                             avp.invoice_id
    ..use
    ap_invoices_v api INNER JOIN ap_invoice_distributions_v aid ON (    api.invoice_id =
                                                                                  aid.invoice_id
                                                                           AND api.invoice_type_lookup_code =
                                                                                  'PREPAYMENT'
                                                                           AND api.invoice_num =
                                                                                  '5'
                                                                          ) LEFT OUTER JOIN ap_apply_prepays_v avp ON (api.invoice_id =
                                                                                                                                             avp.invoice_id
    ...

  • Non-ANSI Outer Join Operator Issue (reposted due to text issues)

    I am currently using Designer 11.5.0.0. Itu2019s XI Rel 2, but Iu2019m not sure what service pack. I have created several universes with outer joins against a SQL Server 2005 database, but when I try using them in a Crystal report, I get the following error:
    Failed to retrieve date from the database. Details: 42000:[Microsoft][ODBC SQL Server Driver][SQL Server] The query uses non-ANSI outer join operators (u201C=u201D or u201C=u201D). To run this query without modification, please set the compatibility level for current database to 80 or lower, using stored procedure sp_dbcmptlevel. It is strongly recommended to rewrite the query using ANSI outer join operators (LEFT OUTER JOIN, RIGHT OUTER JOIN). In the future versions of SQL Server, non-ANSI join operators will not be supported even in backward-compatibility modes.
    Here is my ODBC DSN configuration:
    Microsoft SQL Server ODBC Driver Version 03.85.1132
    Data Source Name: FlexOPS
    Data Source Description:
    Server: dalsvrw031
    Database: (Default)
    Language: (Default)
    Translate Character
    Data: Yes
    Log Long Running Queries: No
    Log Driver Statistics: No
    Use Integrated Security: No
    Use Regional Settings: No
    Prepared Statements Option: Drop temporary procedures on disconnect
    Use Failover Server: No
    Use ANSI Quoted Identifiers: Yes
    Use ANSI Null, Paddings and Warnings: Yes
    Data Encryption: No
    Okay, so I understand what the issue is. It appears that the version of Designer that I am using does not default the ANSI92 parameter to u201CYesu201D. So all the outer joins I have created in each of my universe are using the old *= as the join operator. And apparently, the ODBC driver I am using is not very happy with that.
    As I understand it from what Iu2019ve read on other sites, I have the following options:
    1) Set the ANSI92 parameter to Yes, drop all my joins, close and re-open Designer, and recreate all of the joins.
    2) Find a different driver or connectivity method that will support non-ANSI joins.
    3) Set my database back to SQL 2000 compatibility.
    Option 1 is unappealing as it will cause a lot of time redoing all the work that Iu2019ve spent the past month doing. Option 2 is only a band-aid fix at best. Option 3 really isnu2019t an option for us.

    So I am wondering what other options I have to change these non-ANSI joins to ANSI compatible joins. Do I need to update Designer with a service pack? Is there a script out there that will automatically do this in each of the universes? I would appreciate any suggestions or guidance on this.
    Thanks,
    Lee

  • Non-ANSI Outer Join Operator Issue

    I am currently using Designer 11.5.0.0.  Itu2019s XI Rel 2, but Iu2019m not sure what service pack.  I have created several universes with outer joins against a SQL Server 2005 database, but when I try using them in a Crystal report, I get the following error:
    Failed to retrieve date from the database.
    Details:  42000:[Microsoft][ODBC SQL Server Driver][SQL Server] The query uses non-ANSI outer join operators (u201C=u201D or u201C=u201D).  To run this query without modification, please set the compatibility level for current database to 80 or lower, using stored procedure sp_dbcmptlevel.  It is strongly recommended to rewrite the query using ANSI outer join operators (LEFT OUTER JOIN, RIGHT OUTER JOIN).  In the future versions of SQL Server, non-ANSI join operators will not be supported even in backward-compatibility modes.
    Here is my ODBC DSN configuration:
    Microsoft SQL Server ODBC Driver Version 03.85.1132
    Data Source Name: FlexOPS
    Data Source Description:
    Server: dalsvrw031
    Database: (Default)
    Language: (Default)
    Translate Character Data: Yes
    Log Long Running Queries: No
    Log Driver Statistics: No
    Use Integrated Security: No
    Use Regional Settings: No
    Prepared Statements Option: Drop temporary procedures on disconnect
    Use Failover Server: No
    Use ANSI Quoted Identifiers: Yes
    Use ANSI Null, Paddings and Warnings: Yes
    Data Encryption: No
    Okay, so I understand what the issue is.  It appears that the version of Designer that I am using does not default the ANSI92 parameter to u201CYesu201D.  So all the outer joins I have created in each of my universe are using the old *= as the join operator.  And apparently, the ODBC driver I am using is not very happy with that.
    As I understand it from what Iu2019ve read on other sites, I have the following options:
    1)   Set the ANSI92 parameter to Yes, drop all my joins, close and re-open Designer, and recreate all of the joins.
    2)   Find a different driver or connectivity method that will support non-ANSI joins.
    3)   Set my database back to SQL 2000 compatibility.
    Option 1 is unappealing as it will cause a lot of time redoing all the work that Iu2019ve spent the past month doing.  Option 2 is only a band-aid fix at best.  Option 3 really isnu2019t an option for us.
    So I am wondering what other options I have to change these non-ANSI joins to ANSI compatible joins.  Do I need to update Designer with a service pack?  Is there a script out there that will automatically do this in each of the universes?
    I would appreciate any suggestions or guidance on this.
    Thanks,
    Lee
    Edited by: Lee Vance on Jul 6, 2009 10:02 PM

    Hi,
    try the following:
    open your universe in the Universe designer, go to File->Parameter, select the Parameter tab and change the value of the ANSI92 parameter from No to Yes.
    Regards,
    Stratos

  • URGENT - need help with ansi/iso outer joins

    Hi,
    I am currently preparing for the OCP sql exam for the 9i developer track and I think a statement is printed wrong in my study book, please could somebody confirm the following:-
    Oracle Outer Join syntax
    from tab_a, tab_b
    where a.col_1 (+) = b.col_1
    ANSI/ISO Equivalent
    from tab_a a left outer join tab_b b
    on a.col_1 = b.col_1
    Should n't the above be a right outer join
    Please could somebody confirm or explain if I am wrong.
    Thanks in anticipation.
    Simon
    Note. The book is OCP Introduction to 9i sql (1Z0-007) page 115 (table 3-1) - author Jason Couchman

    It seems so....
    See
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_103a.htm#2107297

  • Bug in either ANSI Join or Oracle 10.2

    I can't tell whose bug this is, but it's almost certainly a bug.
    My co-worker Martin wrote a query (below) that returned zero rows, which he knew was wrong.
    In exploring this further, he discovered that rewriting the join from ANSI 92 to the old WHERE clause join suddenly caused a "ORA-00918: column ambiguously defined" error to arise.
    Then, when he added a table qualifier to one of the column names (effective_dt became fam.effective_dt), suddenly he began to get his data.
    So, here's my question. Why does a query that uses ANSI-92 Join syntax not raise the "ORA-00918: column ambiguously defined" error, WHEN THERE WAS AN AMBIGUOUSLY DEFINED COLUMN? Does the ANSI-92 join syntax imply some sort of hierarchy of table precedence that resolves the ambiguity by implication?
    Here's the query, FYI:
    SELECT fam.asset_mix_percent_nbr
    FROM rp_mip_rpd_fund_asset_mix fam
    JOIN rp_mip_rpd_fund mrf ON fam.rp_mip_rpd_fund_seq =
    mrf.rp_mip_rpd_fund_seq
    JOIN rp_rpd_fund rpd ON mrf.rp_rpd_fund_seq = rpd.rp_rpd_fund_seq
    JOIN rp_psrpd_fund psrpd ON rpd.rp_rpd_fund_seq = psrpd.rp_rpd_fund_seq
    JOIN rp_cpsrpd_fund cpsrpd ON psrpd.rp_psrpd_fund_seq =
    cpsrpd.rp_psrpd_fund_seq
    WHERE rpd.fast_fund_id = LPAD('96', 3, '0')
    AND cpsrpd.cntrct_nbr_id = '800710'
    AND fam.effective_dt =
    -- AND effective_dt = -- this version returns no rows
    (SELECT MAX(fam1.effective_dt)
    FROM rp_mip_rpd_fund_asset_mix fam1
    WHERE fam1.effective_dt <= '03-Oct-07'
    AND fam1.rp_mip_rpd_fund_seq = mrf.rp_mip_rpd_fund_seq);

    We're at 10.2.0.2.0 on a Sun box:
    SunOS saturn1 5.9 Generic_122300-13 sun4u sparc SUNW,Sun-Fire-15000
    The explain plans are identical. Here's one:
    SQL Statement from editor:
    SELECT fam.asset_mix_percent_nbr
    FROM rp_mip_rpd_fund_asset_mix fam
    JOIN rp_mip_rpd_fund mrf ON fam.rp_mip_rpd_fund_seq =
    mrf.rp_mip_rpd_fund_seq
    JOIN rp_rpd_fund rpd ON mrf.rp_rpd_fund_seq = rpd.rp_rpd_fund_seq
    JOIN rp_psrpd_fund psrpd ON rpd.rp_rpd_fund_seq = psrpd.rp_rpd_fund_seq
    JOIN rp_cpsrpd_fund cpsrpd ON psrpd.rp_psrpd_fund_seq =
    cpsrpd.rp_psrpd_fund_seq
    WHERE rpd.fast_fund_id = LPAD('96', 3, '0')
    AND cpsrpd.cntrct_nbr_id = '800710'
    AND effective_dt = -- this version returns no rows
    (SELECT MAX(fam1.effective_dt)
    FROM rp_mip_rpd_fund_asset_mix fam1
    WHERE fam1.effective_dt <= '03-Oct-07'
    AND fam1.rp_mip_rpd_fund_seq = mrf.rp_mip_rpd_fund_seq);
      Statement Id=CB0A0233   Type=SELECT STATEMENT
        Cost=44  TimeStamp=10-DEC-07::06:46:32
           (1)  SELECT STATEMENT  CHOOSE no rows returned
         Est. Rows: 1  Cost: 20
        FILTER
               (13)  TABLE TABLE ACCESS BY INDEX ROWID RP.RP_MIP_RPD_FUND_ASSET_MIX  [Analyzed]
               (13)   Blocks: 5 Est. Rows: 1 of 275  Cost: 1
                    Tablespace: RP
                   (12)  NESTED LOOPS
                        Est. Rows: 1  Cost: 18
                       (10)  NESTED LOOPS
                            Est. Rows: 1  Cost: 17
                           (7)  HASH JOIN
                                Est. Rows: 1  Cost: 16
                               (5)  HASH JOIN
                                    Est. Rows: 20  Cost: 12
                                   (3)  TABLE TABLE ACCESS BY INDEX ROWID RP.RP_CPSRPD_FUND  [Analyzed]
                                   (3)   Blocks: 1,152 Est. Rows: 20 of 75,726  Cost: 6
                                        Tablespace: RP
                                       (2)  INDEX INDEX RANGE SCAN RP.RP_CPSRPD_FUND_F5  [Analyzed]
                                            Est. Rows: 20  Cost: 1
                                   (4)  TABLE TABLE ACCESS FULL RP.RP_PSRPD_FUND  [Analyzed]
                                   (4)   Blocks: 34 Est. Rows: 3,145 of 3,145  Cost: 5
                                        Tablespace: RP
                               (6)  TABLE TABLE ACCESS FULL RP.RP_RPD_FUND  [Analyzed]
                               (6)   Blocks: 13 Est. Rows: 3 of 276  Cost: 3
                                    Tablespace: RP
                           (9)  TABLE TABLE ACCESS BY INDEX ROWID RP.RP_MIP_RPD_FUND  [Analyzed]
                           (9)   Blocks: 5 Est. Rows: 1 of 275  Cost: 1
                                Tablespace: RP
                               (8)  INDEX INDEX RANGE SCAN RP.RP_MIP_RPD_FUND_FK2  [Analyzed]
                                    Est. Rows: 1
                       (11)  INDEX INDEX RANGE SCAN RP.RP_MIP_RPD_FUND_ASSET_MIX_FK1  [Analyzed]
                            Est. Rows: 1
               (16)  SORT AGGREGATE
                    Est. Rows: 1
                   (15)  TABLE TABLE ACCESS BY INDEX ROWID RP.RP_MIP_RPD_FUND_ASSET_MIX  [Analyzed]
                   (15)   Blocks: 5 Est. Rows: 1 of 275  Cost: 2
                        Tablespace: RP
                       (14)  INDEX INDEX RANGE SCAN RP.RP_MIP_RPD_FUND_ASSET_MIX_FK1  [Analyzed]
                            Est. Rows: 1  Cost: 1

  • 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

  • Oracle 9i ansi joins

    Hi
    We are using oracle 9i database ,i want to use asni full outer join for below query .PLease any one how to use ?
    SELECT COLL_SUB_NMBR AS COLL_NO, CLCOLTP, SSUCYL AS CTRY_CD
    FROM TGDW_SGSSUTTRNP, TGDW_PAR_COLL
    WHERE TGDW_PAR_COLL.COLL_SUB_NMBR = TGDW_SGSSUTTRNP.COLLNO
    AND TGDW_PAR_COLL.COLL_TYPE = TGDW_SGSSUTTRNP.CLCOLTP
    AND TGDW_PAR_COLL.COLL_TYPE IN ( 1,21)
    UNION ALL
    SELECT COLL_SUB_NMBR AS COLL_NO, CLCOLTP, FDGCYBNK AS CTRY_CD
    FROM TGDW_SGFDGTRNP, TGDW_PAR_COLL
    WHERE TGDW_PAR_COLL.COLL_SUB_NMBR = TGDW_SGFDGTRNP.COLLNO
    AND TGDW_PAR_COLL.COLL_TYPE = TGDW_SGFDGTRNP.CLCOLTP
    AND TGDW_PAR_COLL.COLL_TYPE = 2
    Regards
    MM

    select COLL_SUB_NMBR, CLCOLTP, a.SSUCYL, b.FDGCYBNK from
    ( TGDW_SGSSUTTRNP join TGDW_PAR_COLL on
        (TGDW_PAR_COLL.COLL_SUB_NMBR = TGDW_SGSSUTTRNP.COLLNO TGDW_PAR_COLL.COLL_TYPE = TGDW_SGSSUTTRNP.CLCOLTP
    AND TGDW_PAR_COLL.COLL_TYPE IN ( 1,21)) a
    full outer join
    ( TGDW_SGFDGTRNP join TGDW_PAR_COLL on
        (TGDW_PAR_COLL.COLL_SUB_NMBR = TGDW_SGFDGTRNP.COLLNO AND TGDW_PAR_COLL.COLL_TYPE = TGDW_SGFDGTRNP.CLCOLTP AND TGDW_PAR_COLL.COLL_TYPE = 2)) b
    using (COLL_SUB_NMBR, CLCOLTP);This is not the same query, because the original query is not using outer join but it may help to figure out on how to use the ansi join syntax
    Regards
    Laurent Schneider
    OCM DBA

  • Ansi standard join

    on toad for oracle it has a build in software for
    non-ANSI to ANSI
    this was the original query
    this new query would run forever, just by looking at the explain plan in toad,
    but what is wrong with it?

    looks like a bug in toad. cross joins create the cartesian product of the two joined tables wich is not what you want. the new query should rather be:
    SELECT p_item_master.item_master_id vid,
           des1,
           p_resv_type.resv_type_code,
           resv_type_desc,
           form_payment_req_yn
       FROM p_resv_type JOIN p_item_master on(P_ITEM_MASTER.ITEM_MASTER_ID=P_RESV_TYPE_ITEM.ITEM_MASTER_ID)
       JOIN p_resv_type_item  on ( P_RESV_TYPE.RESV_TYPE_CODE = P_RESV_TYPE_ITEM.RESV_TYPE_CODE
                  and P_RESV_TYPE_ITEM.PROPERTY_ID=TRIM(pvPropertyCode))
    WHERE p_resv_type_item.property_id = TRIM (pvpropertycode)
    ORDER BY des1
    maybe toad creates better results if you use alias names for your tables...
    bye
    TPD

  • Forms 10g and ANSI joins

    Hello,
    I had thought that Oracle Forms 10g was now fully in line with the 10g database in terms of the SQL and PL/SQL it supports. However, I notice that while I can use ANSI-syntax joins ('inner join', 'left outer join' etc) in record groups, I can't use them in trigger or procedure PL/SQL. For example, the following:
      cursor dist_bacs_csr(c_pln_id plan.id%TYPE)
      is
        select a.id as a_id
             , a.prcng_ccy_cd
             , a.sht_nam
             , a.dist_bac_key1
             , a.dist_bac_key2
        from   asset a
        inner join asset_hldg ash on (a.id = ash.a_id)
        inner join bank_acc bac on (a.dist_bac_key1 = bac.key1 and a.dist_bac_key2 = bac.key2)
        where ash.inc_acc_ind = 'I'
        and   ash.pln_id = c_pln_id
        order by ash.a_id;works fine in SQL Plus, but if I try to include it in my form, I get the error 'Encountered the symbol "INNER" when expecting one of the following: ,; for group having intersect minus order start union where connect'
    Does anyone know if Oracle plan to support ANSI joins in future versions of Forms? Or is there something obvious I'm missing..?
    Cheers,
    James
    Edited by: James Killeen on Aug 31, 2009 8:29 PM (The alias we normally use for the ASSET table apparently triggered the forum's filter against inappropriate language..! Replaced with a nice harmless 'a' instead...)

    Thanks for that - I tried FULL INNER JOIN as well but still wouldn't compile. I'll probably stick with the old-style join format for now, as I don't want to make this a procedure just so I can use the new syntax. A shame, though, as I much prefer the ANSI syntax - would be curious to know if Oracle have any plans to support it in future versions of Forms. Does anyone know if it's supported in Forms 11?

  • ANSI Standard Join with Nested Table

    Does anyone know how to (or whether you actually can) use ansi standard table joins with nested tables.
    Non-ansi standard would look something like this
    SELECT e.empno
    FROM departments d, TABLE(d.employees) e
    WHERE d.deptno = 10;
    Where d.employees is a nested table.
    But if I try ansi-standard I like such:
    SELECT e.empno
    FROM departments d
    JOIN TABLE(d.employees) e
    WHERE d.deptno = 10;
    I get
    ORA-00905: missing keyword
    because I have nothing to join it on.
    Your help is very much appreciated

    Both replies worked fine.
    I think I will go with the NATURAL JOIN as it seems the cleanest option.
    Thanks Guru 2748

Maybe you are looking for