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.

Similar Messages

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

  • 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

  • Need assistance with conditional join in SQL

    Hi All -
    I need to ask for help with this query:
    Create table user_tab_col_test (table_name varchar2(30), column_name varchar2(30), data_type varchar2(30));
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column2', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column3', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column4', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column2', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column3', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column4', 'varchar2')
    Commit;
    Create table all_cons_columns_test (table_name varchar2(30), column_name varchar2(30), constraint_name varchar2(30))
    Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ('table1', 'column1', 'primary')
    Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ('table1', 'column1', 'secondary')
    Commit;
    This is my query and the current result:
    Select u.table_name, u.column_name, c.constraint_name
    From user_tab_col_test u
    Left outer join all_cons_columns_test c
    On ( u.table_name = c.table_name
    AND U.COLUMN_NAME = C.COLUMN_NAME
    AND C.CONSTRAINT_NAME IN ('primary'))
    order by U.table_name, U.COLUMN_NAME;
    TABLE_NAME COLUMN_NAME CONSTRAINT_NAME
    table1 column1 primary
    table1 column2
    table1 column3
    table2 column1
    table2 column2
    Three questions:
    1) I only want to return results where table_name = 'table1'. I can't seem to get this to work.
    2) Is my query proper and is this the best way to return my desired results? I.e. I want all columns from user_tab_col_test and I only want to display the constraint_name from all_cons_columns_test if the constraint_name = 'primary'.
    3) Will the synatx be the same if I need to join a third table to all_cons_columns_test?
    Any advice/suggestions are much appreciated -
    john
    Edited by: user703358 on Jan 11, 2013 8:57 PM
    Edited by: user703358 on Jan 11, 2013 9:48 PM

    Hi,
    user703358 wrote:
    ... ALL_CONSTRAINTS_TEST joins to ALL_CONS_COLUMNS_TEST on TABLE_NAME and CONSTRAINT_NAME. If you adapt this to use the data dictionary views ALL_CONSTRAINTS and ALL_CONS_COLUMNS, then rememeber to join on the OWNER column, also.
    Ultimately I want to use ALL_CONSTRAINTS_TEST.CONSTRAINT_TYPE = 'P' in my WHERE clause, instead of C.CONSTRAINT_NAME IN (primary), only because the constraint_type is a more definitive attribute than just the name of the constraint.
    I tried something like the query below but I'm getting
    ORA-00904: "U"."COLUMN_NAME": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:  
    *Action:
    Error at Line: 8 Column: 16Errors like that are caused by trying to mix old join syntax with ANSI join syntax in the same query.
    SELECT    u.table_name
    ,       u.column_name
    ,       C.CONSTRAINT_NAME
    FROM           USER_TAB_COL_TEST      U,
    ALL_CONSTRAINTS_TEST ACAbove is an example of an old-style join: there is a comma between the table names, and the join conditions are included in the WHERE clause below.
    LEFT OUTER JOIN  all_cons_columns_test  c
    ON    u.table_name    = c.table_name
    AND   U.COLUMN_NAME    = C.COLUMN_NAMEThis is an example of an ANSI-style join: the keyword JOIN appears between the table names, and the join conditions are right here, after the keyword ON.
    WHERE      U.TABLE_NAME    = 'table1'
    AND C.TABLE_NAME = AC.TABLE_NAME
    AND C.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
    and AC.CONSTRAINT_TYPE = 'P'
    ORDER BY  u.table_name
    ,           u.column_name
    ;While it is possible to use both join styles in the same query, it's a really bad idea. I suggest always using ANSI syntax, especially for outer joins, but whatever style you choose, use it consistently for all joins in the same query.
    In this case, you want an inner join between tablec c and ac, so the ANSI syntax would be something like
    FROM  u  LEFT OUTER JOIN c ON ... JOIN ac ON ...In this case, it's very important that the inner join between c and ac is done before the outer join with u. How can you make sure that happens? Well, if you have an arithmetic expression such as
    12 * 5 - 1and you want to make sure the subtraction of 1 from 5 takes place before the multiplication by 12, what do you do? You can add parentheses:
    12 * ( 5 - 1 )In ANSI join syntax, you can use parentheses the same way:
    FROM  u  LEFT OUTER JOIN ( c ON ... JOIN ac ON ... )or, in full:
    SELECT    u.table_name
    ,        u.column_name
    ,        c.constraint_name
    ,       ac.constraint_type
    FROM             user_tab_col_test      u
    LEFT OUTER JOIN  (
                             all_cons_columns_test  c
               JOIN  all_constraints_test   ac
                                 ON   ac.table_name     = c.table_name
                          AND  ac.constraint_name     = c.constraint_name
                            ON    u.table_name       = c.table_name
                   AND   u.column_name       = c.column_name
                   AND   ac.constraint_type  = 'P'
    WHERE       u.table_name     = 'table1'
    ORDER BY  u.table_name
    ,            u.column_name
    ;Output:
    TABLE_NAME COLUMN_NAME CONSTRAINT_NAME CONSTRAINT_TYPE
    table1     column1     primary         P
    table1     column2
    table1     column3
    table1     column4

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

  • Need help with conditional join....

    Table 1 - Student
    ID# Name
    1 # A
    2 # B
    3 # C
    4 # D
    Table2 - Marks
    ID Marks Display
    1 # 10 # Y
    1 # 20 # Y
    1 # 14 # N
    2 # 12 # N
    2 # 13 # N
    3 # 12 # Y
    Result...Need query to do this?..
    Want to join above two tables and display marks as X when there is no ID in table marks or there is ID but all marked with display as 'N'...if there is one or more
    marked with Y then display with marks..
    I am using oracle 11i.
    ID NAme      Marks
    1 # A     #     10
    1 # A     #     20
    2 # B # X
    3 # C # 12
    4 # D # X

    Or, using ANSI join syntax:
    with Table1 as (
                    select 1 id,'A' name from dual union all
                    select 2,'B' from dual union all
                    select 3,'C' from dual union all
                    select 4,'D' from dual
         Table2 as (
                    select 1 id,10 marks,'Y' display from dual union all
                    select 1,20,'Y' from dual union all
                    select 1,14,'N' from dual union all
                    select 2,12,'N' from dual union all
                    select 2,13,'N' from dual union all
                    select 3,12,'Y' from dual
    -- end of on-the-fly data sample
    select  t1.id,
            name,
            nvl(to_char(marks),'X') marks
      from      Table1 t1
            left join
                Table2 t2
              on (
                      t2.id = t1.id
                  and
                      display = 'Y'
      order by id
            ID NAME                                                    MARKS
             1 A                                                       10
             1 A                                                       20
             2 B                                                       X
             3 C                                                       12
             4 D                                                       X
    SQL> SY.

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

  • 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

  • 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 Internal tables in Start Routine

    Hi,
    I have intenal table some IT_A which deletes the requests which are populated in to it.
    Now I need to populate requests into IT_A from  another internal table like IT_B which are of different structure.
    I have three fields in common in both internal tables like RNR,Timestamp n SID with different field names
    I Need Clarification that if i move the contents of the three fields to IT_A from IT_B by spcifying these three fields.Will the internal table IT_A deletes the Requests?
    Thanks,
    Sriram.

    Hi Sriram,
    As mentioned IT_A deleted the request loaded into it.
    if you move the contents of the three fields to IT_A from IT_B by spcifying the three fields after the deletion step for internal table IT_A takes place then it wont get deleted.
    But it would be deleted if the the contents are moved before the deletion step takes place
    regards,
    mahesh

  • Need clarification on issue with tablespaces

    Hi All,
    I needed clarification on this issue with tablespaces.I am following a guideline which says "Presently,The general rule of thumb is to concentrate on tablespaces that are 90% or greater used and have less than 2 GB of free space"
    My Scenario:-Now i have tablesace which is 97.23 % and the free space is 10 gb.Please advise me that whats the best next step I can take in this respect?
    I am very new to this and just following the guideline,so can you all please explain me some details about this.
    Thanks

    Well, the guideline says "*and* have less than 2 GB of free space"
    Since that tablespace as 10GB of free space, the guideline says that you do not need to concentrate on it. Eh ?
    I would be careful with guidelines that are hard-coded in this manner. You need to know the context in which the guideline was set.
    Assuming that your database/application doesn't grow suddenly by 1GB or larger (or create temporary segments / objects of 1GB or larger), the "2 GB of free space" might make sense. Then, again, it depends on the extent allocation type. What size are extents getting allocated.
    You should check with your organisation's senior DBAs on what happens if you don't concentrate on a tablespace because it is outside the guidelines !

  • Need clarification on Bigfile Tablespaces

    In the following Oracle Documentation Lirbary PDF,
        Oracle® Database
        Concepts
        10g Release 2 (10.2)
        B14220-02
        October 2005
    section
        Overview of Tablespaces
        Bigfile Tablespaces (page: 3-5)
    it says,
        Benefits of Bigfile Tablespaces
        * Bigfile tablespaces can significantly increase the storage capacity of an Oracle database. Smallfile tablespaces can contain up to 1024 files, but bigfile tablespaces contain only one file that can be 1024 times larger than a smallfile tablespace. The total tablespace capacity is the same for smallfile tablespaces and bigfile tablespaces. However, because there is a limit of 64K database for each database, a database can contain 1024 times more bigfile tablespaces than smallfile tablespaces, so bigfile tablespaces increase the total database capacity by 3 orders of magnitude. In other words, 8 exabytes is the maximum size of the Oracle database when bigfile tablespaces are used with the maximum block size (32k).
    I need clarification on how to arrive at 8 exabytes ?
    1024 x 32k x 64,000 ??
    According to the exerpt above, there's no mention of maximum number of Operating System blocks per extent. Unless this was assumed knowledge ... how do I get 8 exabytes ?
    And if "a database can contain 1024 times more bigfile tablespaces than smallfile tablespaces", then what's the upper limit on smallfile tablespaces ? -- was this sentence referring to the number of datafiles per smallfile tablespace ? ...
    O_o
    Thanks !
    Message was edited by:
    mvanle

    Hi,
    According to [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14237/limits002.htm#i287915]Physical Database Limits page, a bigfile tablespace contains only one datafile or tempfile, which can contain up to approximately 4 billion ( 232 ) blocks. The maximum size of the single datafile or tempfile is 128 terabytes (TB) for a tablespace with 32K blocks and 32TB for a tablespace with 8K blocks. In resume, A bigfile tablespace is a tablespace containing a single datafile that can be as large as 128 terabytes (TB), depending on the block size of the tablespace. In conjunction with setting the initialization parameter DB_FILES to the maximum value of 65,635 the total size of the database can be more than 8 exabytes (EB)
    >>how do I get 8 exabytes ?
    You can calculate the maximum amount of space (M) in a single Oracle database as the maximum number of datafiles (D) multiplied by the maximum number of blocks per datafile (F) multiplied by the tablespace block size (B):
    M = D * F * B. Therefore, the maximum database size, given the maximum block size and the maximum number of datafiles, is:
    65,535 datafiles * 4,294,967,296 blocks per datafile * 32,768 block size = 9,223,231,299,366,420,480 = 8EB.Cheers
    Legatti

  • 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'))

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

Maybe you are looking for

  • JFrame (menubar) problem

    Hi, I have a JFrame with few JPanels on it ( those in turn have JButtons etc). JFrame has the ussual menubar ( set using setJMenuBar) . Menubar is not accessiable using <TAB> . All other items are. Any ideas? Thank you in advence for any help.

  • Move iMovie event to DVD before editing for storage

    Hello, I need to move a few iMovie events to DVD before editing to free up some space on my MBP. I'm making room for a live AV recording and have no idea how much space I will need. Will moving the event cause any problems? How is an event burned to

  • Failed on Viewing an Explain Plan

    I have some error while trying to show the query tree plan. After I entered SQL commands and I click 'explain', it didn't show anything. There suppose to be showing some kind of query tree right? But it just a blank space. Am I doing it wrong? Or the

  • How to insert interstitial video between menu and track?

    I've been making simple menus in DVD Studio Pro, but I'm trying to make a Menu for someone who wants a short video to play before the Menu loads (on start up) and then a short video to play after you make a Menu selection (but before it actually play

  • Clear Instructions: import Vinyl records into iTunes

    I have been researching for some weeks. Amazing,no succinct article or info on HOW to use a Mac and import music from Vinyl records into iTunes. ( Adam Engst, where is a Tidbits eBook when I need it?) I think I have the gist but maybe you audiophiles