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

Similar Messages

  • Difference between oracle join syntaxes and ANSI join syntaxes

    What is difference between oracle join syntaxes and ANSI join syntaxes ?
    why oracle is having different syntaxes for joins than ANSI syntaxes ?
    Also Join syntaxes are different in some oracle vesrions ?

    BluShadow wrote:
    3360 wrote:
    Yes it is. The Oracle database wasn't initially designed to be ANSI compliant. As you correctly state the ANSI standards weren't around when it was initially designed, so the statement is perfectly correct. ;)Ok, in one sense it may be correct but it is a completely misleading statement. Not sure why you think it's misleading.Because there was no ANSI standard, so making it sound like a design choice The Oracle database wasn't initially designed to be ANSI compliant. would suggest to most readers that there was a standard to be compliant to.
    Like saying Ford originally did not design their cars to incorporate safety features such as ABS, seat belts and air bags.
    The OP asked "why oracle is having different syntaxes for joins than ANSI syntaxes ?" and the answer is that Oracle wasn't initially designed with ANSI compliance, so it has it's old non-ANSI syntax,As shown above, the old syntax was ANSI compliant at the time and to call it non-ANSI is either incorrect or misleading dependent on your point of view.
    and since ANSI syntax became the standard it now supports that. And since ANSI switched to a new standard, Oracle had to implement the new standard as well as the previous ANSI standard would be more accurate in my opinion.
    Nothing misleading as far as I'm aware in that.I find the whole discussion about ANSI and Oracle's supposed non-compliance, reads like it was Oracle's choice to deviate from the standards, when it was ANSI's bullheaded decisions to pointlessly change standards that left Oracle and other vendors out of compliance, and that was a decision made solely by ANSI.
    This is probably the reason ANSI no longer produces SQL standards, the endless syntax fiddling would eventually have made forward left under outer joins a reality.
    {message:id=1785128}

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

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

  • Flow accept error when using ANSI join syntax

    Hi
    I had a region populated by a query joining two views (one in-line using connect by). When trying to create the region if the join was coded using ANSI syntax (INNER JOIN .... USING) I got a flow accept error when either trying to proceed using the wizard, or apply changes when editing the region.
    After changing to the old style Oracle join (using predicates), I was able to create the region and everything worked ok. I found the solution after reading this post Error 404 wwv_flow.accept was not found in which the OP says he would raise a bug. Did the bug get raised? I ask since his problem arose whilst he was selecting from a view using ANSI joins and using instead of triggers, and I was joining an in-line view to a view using ANSI joins and instead of triggers, but neither view has been changed, just the join syntax. The view defined in the database is used in other regions and works fine. This could indicate the OP's problem was fixed, but one still exists.
    Incidentally this is the only time I have used non-ANSI joins in the entire apex app - the rest work!. Unfortunately it is impossible for me to demo the app.
    Richard
    using ApEx 3.0.1.00.07 and 10g (10.2.0.1) EE on Wintel

    Tyler,
    Apologies, what I was trying to say was that I couldn't put the application on the Oracle APEX site.
    Yes, I do have a work-around, but that does not mean a bug may still exist. I count myself fortunate I saw that post and, therefore, experimented with the syntax of the join - there is no reason APEX should not accept ANSI join conditions, in fact , it does. The ANSI-joined SQL statement executed perfectly in TOAD and SQL*Plus, but I could not even save it in APEX.
    regards
    Richard

  • Need clarification on ANSI Joins

    Hi All,
    I need some clarification on the ANSI Join which I build to avoid an error when I am trying to execute the same in regular join.
    With Regular join I am getting the error ORA-01417: a table may be outer joined to at most one other table.
    Regular Join Condition:
    select null
    FROM
    land_event_device_fraud T1, --Update Dealer
    land_event_device_upgrade T2, --New Subscriber First Set
    syn_intg_event_device_state T3, --Existing Subscriber
    land_event_device_upgrade T4 --New Subscriber Second Set       
    WHERE T1.event_id = T2.event_id(+) AND T1.rate_plan_id = T2.rate_plan_id(+)
    AND T1.event_id = T3.event_id(+) AND T1.rate_plan_id = T3.rate_plan_id(+)
    AND T4.event_id = T1.event_id(+) AND T4.event_id = T1.rate_plan_id(+)
    AND T4.event_id = T3.event_id(+) AND T4.event_id = T3.rate_plan_id(+);
    --Getting error ORA-01417.
    Replaced the above join with ANSI Join
    SELECT NULL
    FROM land_event_device_fraud t1
    LEFT OUTER JOIN land_event_device_upgrade t2
    ON (t1.event_id = t2.event_id AND t1.rate_plan_id = t2.rate_plan_id)
    LEFT OUTER JOIN syn_intg_event_device_state t3
    ON (t1.event_id = t3.event_id AND t1.rate_plan_id = t3.rate_plan_id),
    land_event_device_upgrade t4
    LEFT OUTER JOIN land_event_device_fraud t5
    ON (t4.event_id = t5.event_id AND t4.rate_plan_id = t5.rate_plan_id)
    LEFT OUTER JOIN syn_intg_event_device_state t6
    ON (t4.event_id = t6.event_id AND t4.rate_plan_id = t6.rate_plan_id);
    I want to know whether the ANSI Join is goig to work fine or it is going to give me any cartesian production information.
    Appreciate your help here.
    Thanks,
    MK.

    Hi,
    Maddy wrote:
    Hi All,
    I need some clarification on the ANSI Join which I build to avoid an error when I am trying to execute the same in regular join.
    With Regular join I am getting the error ORA-01417: a table may be outer joined to at most one other table.
    Regular Join Condition:
    select null
    FROM
    land_event_device_fraud T1, --Update Dealer
    land_event_device_upgrade T2, --New Subscriber First Set
    syn_intg_event_device_state T3, --Existing Subscriber
    land_event_device_upgrade T4 --New Subscriber Second Set       
    WHERE T1.event_id = T2.event_id(+) AND T1.rate_plan_id = T2.rate_plan_id(+)
    AND T1.event_id = T3.event_id(+) AND T1.rate_plan_id = T3.rate_plan_id(+)
    AND T4.event_id = T1.event_id(+) AND T4.event_id = T1.rate_plan_id(+)
    AND T4.event_id = T3.event_id(+) AND T4.event_id = T3.rate_plan_id(+);
    --Getting error ORA-01417.
    Replaced the above join with ANSI Join
    SELECT NULL
    FROM land_event_device_fraud t1
    LEFT OUTER JOIN land_event_device_upgrade t2
    ON (t1.event_id = t2.event_id AND t1.rate_plan_id = t2.rate_plan_id)
    LEFT OUTER JOIN syn_intg_event_device_state t3
    ON (t1.event_id = t3.event_id AND t1.rate_plan_id = t3.rate_plan_id),
    land_event_device_upgrade t4
    LEFT OUTER JOIN land_event_device_fraud t5
    ON (t4.event_id = t5.event_id AND t4.rate_plan_id = t5.rate_plan_id)
    LEFT OUTER JOIN syn_intg_event_device_state t6
    ON (t4.event_id = t6.event_id AND t4.rate_plan_id = t6.rate_plan_id);You're mixing ANSI joins and old joins. That's very confusing. Use all of one kind or all of the other.
    >
    I want to know whether the ANSI Join is goig to work fine or it is going to give me any cartesian production information.What happens when you try it? Does it produce the results you want?
    Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. Explain how you get those results from that data.
    Always say which version of oracle you're using.
    See the forum FAQ {message:id=9360002}
    Why does the SELECT clause include only NULL? Is this going to be used as an EXISTS sub-query? If so, why bother to do outer joins, and why do you care if it does a Cartesian product? What is the compete query?
    For debugging purposes, you might want to include something that you can see in the SELECT clause.

  • 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

  • Use ansi join syntax

    From what i have been reading is better to use the new syntax(dont know how new it is)

    The ANSI join syntax was new to Oracle in Oracle 8i in 1998 - that's 15 years old.
    It can produce more readable code, and is both more readable and less human-error prone for outer joins.
    The ANSI format lets you outer join between multiple tables in a way the old oracle-specific ( + ) syntax did not and introduces FULL OUTER JOIN which you should use very rarely.
    You should not use NATURAL JOIN in code - adding unrelated columns to the tables involved can make it give very different results.
    There have not been significant bugs for ANSI joins in Oracle since Oracle 10.2 was introduced about 8 years ago.
    As Paul said, the ON part should be the join criteria between the tables. The were clause should be the filtering of the joined tables.
    So assuming start_date, end_date and in_property_id are variables
    SELECT resv_num, unit_date
        FROM p_resv_unit ru
        INNER JOIN p_pm_unit_night pun
        ON pun.resv_unit_id = ru.resv_unit_id
        WHERE pun.property_id = in_property_id
        AND pun.unit_date BETWEEN start_date AND end_date
        AND pun.pm_unit_num = cvUnitNum;
    If start_date and end_date were columns in p_resv_unit the query would be:
    SELECT resv_num, unit_date
        FROM p_resv_unit ru
        INNER JOIN p_pm_unit_night pun
        ON pun.resv_unit_id = ru.resv_unit_id AND pun.unit_date BETWEEN ru.start_date AND ru.end_date
        WHERE pun.property_id = in_property_id
            AND pun.pm_unit_num = cvUnitNum;
    Inner join queries work with criteria in the wrong place, but they're harder to read. Outer joins don't work unless you put the criteria in the right place.

  • Help need for ansi join

    This is the sample piece of code in oracle which I am trying to convert it to ANSI join kindly help all the in_ and P_ and v_ are coming as a in parameter
    select *
    FROM    fxrates_v fx1
    WHERE fx1.fx_close(+) = in_fx_close AND
               fx1.fxrate_currency (+) =   decode (v_agree_type, 'L', upper(v_pledge_leh_unsec_curr) ,
                                                     'C', upper(v_pledge_cp_unsec_curr),
                                                     decode(sign(v_pre_mrgn_val), -1, upper(v_pledge_leh_unsec_curr),
                                                     upper(v_pledge_cp_unsec_curr)))/

    Michael I think your one is not equivalent to the OP's one.
    Let's see an example on EMP:
    SQL> select * from emp
      2  where comm(+) = 300;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
    SQL> select * from emp
      2  where comm(+) = null;
    no rows selected
    SQL> select * from emp right outer join dual on comm = 300;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO D
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30 X
    SQL> select * from emp right outer join dual on comm = null;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO D
                                                                                          XIf you add the right outer join on dual and the input parameter is null you extract an all nulls row.
    But the original query doesn't behave this way, the .(+) symbols have no effect on the result either if the input parameter is not null and if it is null...
    This is why I simply ignored them in my re-arrangement...
    So I think you can't convert the original query in ANSI sql preserving the behaviour...
    Am I missing something?
    Max
    http://oracleitalia.wordpress.com

  • One question that Ansi join convert to (+)

    Hi,
    Original sql as below:
    left join limit_order on limit_order.id = active_request_leg_map.DEAL_ID and limit_order.rita_deal_id = request.rita_deal_id
    I want to use (+) instead of Ansi join, how to do it?
    Thanks
    Edited by: user886998 on 2011-4-4 下午9:01
    Edited by: user886998 on 2011-4-4 下午9:02
    Edited by: user886998 on 2011-4-4 下午9:05
    Edited by: user886998 on 2011-4-4 下午9:06

    Hi,
    Welcome to the forum!
    user886998 wrote:
    Original sql as below:
    left join limit_order on limit_order.id = active_request_leg_map.DEAL_ID and limit_order.rita_deal_id = request.rita_deal_id
    I want to use (+) instead of Ansi join, how to do it?Why? Are you using Oracle 8 (or earlier)? That's the only good reason for using non-ANSI joins, especially for outer joins.
    Whenever you post a question, say which version of Oracle you're using.
    If you really must do this without ANSI joins, then join active_request_leg_map and request in a sub-query, and then join limit_order to that result set.
    SELECT  ...
    FROM    (
                SELECT  a.deal_id
                ,       r.rita_deal_id
                FROM    active_request_leg_map  a
                ,       request                 r
                WHERE   ...
            )            sq
    ,       limit_order  lo
    WHERE   lo.id (+)            = sq.deal_id
    AND     lo.rita_deal_id (+)  = sq.rita_deal_id
    ...If you'd care to post a little sample data (CREATE TABLE and INSERT statements for all tables) and the results you want from that data, then I could show you exactly, and test it.

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

  • Solution  to work in ANSI Join Condition

    Hi All,
    I am having one query which is using ANSI join syntax.
    The table TMP_GL_DATA having 237 records, when I am running the below query giving 237 records only if I remove the condition
    key word ' WHERE 1=1 ', ELSE ITS GIVING 0 records.
    How to give where condition if we use more than one table join with single table.
    If any one have ideal please let me know..
    See the below query for your reference.
         SELECT *
         FROM TMP_GL_DATA
         left outer join FCT_TP_RATES ON TMP_GL_DATA.v_repline1_code = FCT_TP_RATES.v_repline1_code
         left outer join FCT_NONCUST_PROD_TP_RATES ON TMP_GL_DATA.v_repline1_code = FCT_NONCUST_PROD_TP_RATES.v_repline1_code
         AND TMP_GL_DATA.v_prod_code = FCT_NONCUST_PROD_TP_RATES.v_prod_code
         AND TMP_GL_DATA.v_gl_ccy_code = FCT_NONCUST_PROD_TP_RATES.v_ccy_code
         inner join DIM_PRODUCT ON TMP_GL_DATA.v_prod_code = DIM_PRODUCT.v_prod_code
         left outer join VW_EFP_ADJ_RECORDS ON TMP_GL_DATA.v_gl_code = VW_EFP_ADJ_RECORDS.v_gl_code
         AND TMP_GL_DATA.v_lv_code = VW_EFP_ADJ_RECORDS.v_lv_code
         AND TMP_GL_DATA.v_gl_ccy_code = VW_EFP_ADJ_RECORDS.v_gl_ccy_code
         AND TMP_GL_DATA.v_branch_code = VW_EFP_ADJ_RECORDS.v_branch_code
         WHERE 1=1
         AND TMP_GL_DATA.V_GL_TYPE IN (Fn_I18n('L', 48),Fn_I18n('L', 51))
         AND TMP_GL_DATA.v_process_flag = 'A'
         AND TMP_GL_DATA.fic_mis_date = TO_DATE('20060601','YYYYMMDD')
         AND dim_product.f_latest_record_indicator = 'Y'
         AND fct_tp_rates.fic_mis_date = (SELECT MAX(fic_mis_date)
         FROM fct_tp_rates a
         WHERE a.v_repline1_code = a.v_repline1_code
         AND a.fic_mis_date <= TO_DATE('20060601','YYYYMMDD'))
         AND fct_noncust_prod_TP_RATES.FIC_MIS_DATE = (SELECT MAX(FIC_MIS_DATE)
         FROM fct_noncust_prod_tp_rates a
                                                                WHERE a.v_repline1_code = v_repline1_code
                                                                AND a.v_prod_code = v_prod_code
                                                                AND a.v_ccy_code = v_ccy_code
                                                                AND a.fic_mis_date <=TO_DATE('20060601','YYYYMMDD'))

    if you query is something like this that is giving you 0 records:
    SELECT *
      FROM TMP_GL_DATA
      left outer join FCT_TP_RATES ON TMP_GL_DATA.v_repline1_code = FCT_TP_RATES.v_repline1_code
      left outer join FCT_NONCUST_PROD_TP_RATES ON TMP_GL_DATA.v_repline1_code = FCT_NONCUST_PROD_TP_RATES.v_repline1_code
                 AND TMP_GL_DATA.v_prod_code = FCT_NONCUST_PROD_TP_RATES.v_prod_code
                 AND TMP_GL_DATA.v_gl_ccy_code = FCT_NONCUST_PROD_TP_RATES.v_ccy_code
      inner join DIM_PRODUCT ON TMP_GL_DATA.v_prod_code = DIM_PRODUCT.v_prod_code
      left outer join VW_EFP_ADJ_RECORDS ON TMP_GL_DATA.v_gl_code = VW_EFP_ADJ_RECORDS.v_gl_code
                 AND TMP_GL_DATA.v_lv_code = VW_EFP_ADJ_RECORDS.v_lv_code
                 AND TMP_GL_DATA.v_gl_ccy_code = VW_EFP_ADJ_RECORDS.v_gl_ccy_code
                 AND TMP_GL_DATA.v_branch_code = VW_EFP_ADJ_RECORDS.v_branch_code
       AND TMP_GL_DATA.V_GL_TYPE IN (Fn_I18n('L', 48),Fn_I18n('L', 51))
       AND TMP_GL_DATA.v_process_flag = 'A'
       AND TMP_GL_DATA.fic_mis_date = TO_DATE('20060601','YYYYMMDD')
       AND dim_product.f_latest_record_indicator = 'Y'
       AND fct_tp_rates.fic_mis_date = (SELECT MAX(fic_mis_date)
                                          FROM fct_tp_rates a
                                         WHERE a.v_repline1_code = a.v_repline1_code
                                           AND a.fic_mis_date <= TO_DATE('20060601','YYYYMMDD'))
                                           AND fct_noncust_prod_TP_RATES.FIC_MIS_DATE = (SELECT MAX(FIC_MIS_DATE)
                                                                                           FROM fct_noncust_prod_tp_rates a
                                                                                          WHERE a.v_repline1_code = v_repline1_code
                                                                                            AND a.v_prod_code = v_prod_code
                                                                                            AND a.v_ccy_code = v_ccy_code
                                                                                            AND a.fic_mis_date <=TO_DATE('20060601','YYYYMMDD'))you might want to try this:
    SELECT *
      FROM TMP_GL_DATA
      left outer join FCT_TP_RATES ON TMP_GL_DATA.v_repline1_code = FCT_TP_RATES.v_repline1_code
      left outer join FCT_NONCUST_PROD_TP_RATES ON TMP_GL_DATA.v_repline1_code = FCT_NONCUST_PROD_TP_RATES.v_repline1_code
                 AND TMP_GL_DATA.v_prod_code = FCT_NONCUST_PROD_TP_RATES.v_prod_code
                 AND TMP_GL_DATA.v_gl_ccy_code = FCT_NONCUST_PROD_TP_RATES.v_ccy_code
      inner join DIM_PRODUCT ON TMP_GL_DATA.v_prod_code = DIM_PRODUCT.v_prod_code
      left outer join VW_EFP_ADJ_RECORDS ON TMP_GL_DATA.v_gl_code = VW_EFP_ADJ_RECORDS.v_gl_code
                 AND TMP_GL_DATA.v_lv_code = VW_EFP_ADJ_RECORDS.v_lv_code
                 AND TMP_GL_DATA.v_gl_ccy_code = VW_EFP_ADJ_RECORDS.v_gl_ccy_code
                 AND TMP_GL_DATA.v_branch_code = VW_EFP_ADJ_RECORDS.v_branch_code
    WHERE TMP_GL_DATA.V_GL_TYPE IN (Fn_I18n('L', 48),Fn_I18n('L', 51))
       AND TMP_GL_DATA.v_process_flag = 'A'
       AND TMP_GL_DATA.fic_mis_date = TO_DATE('20060601','YYYYMMDD')
       AND dim_product.f_latest_record_indicator = 'Y'
       AND fct_tp_rates.fic_mis_date = (SELECT MAX(fic_mis_date)
                                          FROM fct_tp_rates a
                                         WHERE a.v_repline1_code = a.v_repline1_code
                                           AND a.fic_mis_date <= TO_DATE('20060601','YYYYMMDD'))
                                           AND fct_noncust_prod_TP_RATES.FIC_MIS_DATE = (SELECT MAX(FIC_MIS_DATE)
                                                                                           FROM fct_noncust_prod_tp_rates a
                                                                                          WHERE a.v_repline1_code = v_repline1_code
                                                                                            AND a.v_prod_code = v_prod_code
                                                                                            AND a.v_ccy_code = v_ccy_code
                                                                                            AND a.fic_mis_date <=TO_DATE('20060601','YYYYMMDD'))

  • ANSI join syntax with code-insight

    I've noticed that SQL Developer 1.1.3 doesn't perform code-insight into table aliases when I use the ANSI join sytax. Is there a configuration option to make this possible or does it just not exist yet?

    Hi,
    Currently on SQL Developer 1.2, Windows XP, and Database 9.2
    I have the same problem too.
    The Code-Insight is unable to show the Code Completion for aliased table name in ANSI JOIN
    SELECT *
    FROM    Schema1.Table1 t1
    INNER JOIN Schema1.Table2 t2 ON t2.     -- cannot show the code-insightHowever the following code works just fine for the code-insight
    SELECT *
    FROM    Schema1.Table1 t1,
                  Schema1.Table2 t2
    WHERE t1.Field1 = t2.Field1Any suggestion?
    Regards,
    Buntoro

  • Ansi join standards

    Just wondering if someone could tell me what the syntax is for an Ansi join which joins on two or more columns. For example:
    select *
    from emp e,
         dept d
    where e.dept_no = d.dept_np
    and   e.mgr_no = d.mgr_no I've tried a few variations such as repeating the on clause but that doesn't seem to work. Any help would be appreciated.

    select *
      from emp e
      join dept d
         on (e.dept_no = d.dept_np and   e.mgr_no = d.mgr_no)

  • Joining multiple tables using ANSI join

    Hi,
    I need to join 4 tables using ANSI join. Lets say they are A,B,C adn D. A and B has a common column called x. C and D had a common column called y. I wrote a query like this
    select * from A left outer join B on (A.x=B.x),
    C left outer join D on (C.y =D.y)
    its not working!!!
    I need to use ANSI join.
    can any body help me please???

    Hi,
    But is there is any common column between A,C or B,C or D,A?
    Let me know.

Maybe you are looking for

  • Where is the jar file includes ejb3.0 interface

    I just start using ejb 3.0, when i create a stateless session bean, i can not find the Stateless interface when import javax.ejb.Stateless. Appreciated if someone can let me which jar file includes those interface (like javax.ejb.Remove, javax.ejb.St

  • Sound suddenly stopped working.

    Hi, my sound on my HP ENVY 15 Notebook PC just suddenly stopped working the other day. Everything says that it is functioning, and my drivers are up to date, but I cannot seem to get the sound to work out of my speakers or out of headphones.  Product

  • How to extract a users designate rights or group contacts

    Greetings, We're running OCS9.0.4.2 on RedHat EL3 In Calendar, how do I extract a users designate rights or their personal groups? I'm unable to find a way to do this using any of the 'uni' Calendar Server Utilities or Calendar SDK. I am intending to

  • Export/Import web form

    I exported a bunch of web forms from my dev environment and imported them into production. The security assigned to the forms did not get imported. Does anyone know if there is there a way to import the security for the forms that are being imported?

  • Conflict between the saved data and the sampling rate and samples to read using PXI 6070e

    Hello, I am using PXI 6070e to read an analog voltage. I was sampling at 6.6 MHz and the samples to read were 10. So, that means it should sample 10 points every 1.5 um. The x-axis of the graph on the control panel was showing ns and us scale, which