ANSI/9i Join Syntax and Pretty Code

I've always tried to keep my SQL statement code formatted in a way that I think helps readability. I picked up the following style because I found it easy to quickly find the FROM clause and the JOINS or conditions:
select e.ename,
       e.sal,
       d.dname
from   emp e,
       dept d
   * Joins
where  e.deptno = d.deptno
   * Conditions
and    d.dname = 'SALES'
/Of course, for such a simple query I wouldn't have used the comments to divide the WHERE clause into joins and conditions...
Anyway, since Tom Kyte and the 9i documentation suggest using the ANSI join syntax (amongst other reasons), I have decided to begin changing my ways. However, I am having troubles figuring out how to format my SQL to still be "pretty."
For the previous example, a new formatting style seems easy:
select e.ename,
       e.sal,
       d.dname
from   emp e
  join dept d          on e.deptno = d.deptno
where  d.dname = 'SALES'
/Now, when we use an example that has optional joins is where I can't figure what my style should be:
select e.ename,
       m.ename as manager
from        emp e
  left join emp m      on e.mgr = m.empno
where  e.deptno = 10
/I don't really like this style since it gets so wide, causing problems when indenting for subqueries/inline-views. It also looks kinda clunky because the tables are indented more than everything else...
Anyway, since I don't want to spend a bunch of time figuring out things like style, I'd like to see what other formats people are using. I'd appreciate seeing how others are formatting thier SQL when using the new 9i (old-ANSI) syntax.
Thanks, Stan

That looks to me like left aligned (but I may be on the wrong side of the looking glass...)
By preference is to left-align the KEYWORDS and the data words, using indentation to distinguish the start of the different clauses (SELECT, FROM, WHERE, ORDER BY, etc.). This approach is easily standardised with Textpad or similar editing tools. Quite how one programs a text editor to turn one's code into a Rorschach blot is beyond me.
I haven't done much with ANSI joins, so I hadn't come up with a standard for layout. The following is what I think I would do if I ever had to, and is basically an adaption of what I do now ...
FROM   user_indexes i
       , user_ind_columns ic2
       , user_tab_columns c2with the ANSI join stuff indented and aligned. I find rigourous application of UPPER and lower case tends to assist clarity: indentation and alignment are not enough.
SELECT i.table_name
       , i.index_name
       , ic2.column_position
FROM   user_indexes i
       INNER JOIN user_ind_columns ic2
       ON i.table_name = ic2.table_name
       AND i.index_name = ic2.index_name
       INNER JOIN user_tab_columns c2
       ON ic2.table_name = c2.table_name
       AND ic2.column_name = c2.column_name
WHERE  i.uniqueness='UNIQUE'
ORDER  BY i.table_name
       , i.index_name
       , ic2.column_position
/

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}

  • ANSI inner join syntax

    Hi,
    Is there a way to configure BI Server 11g to generate ANSI join sytax ("INNER JOIN" clause) for Oracle, as it does when using OUTER JOINs?
    Thank you.

    OBIEE will not generate ANSI syntax for Inner Joins and as you said it only generates for Outer joins. Hope this clears your doubt.

  • ANSI/ISO JOIN SYNTAX

    DEAR Friends,
    How can i write the ansi/iso syntax for below query
    select a.company,b.fpm_ac_code from facmast a,fparty b, fstatus c
    where a.company = b.company(+)
    and a.fac_ac_code = b.fpm_ac_code(+)
    and a.company = c.company(+)
    one method is
    select a.company ,b.fpm_ac_ccode from facmast a right outer join fparty b on a.company = b.company
    and a.fac_ac_code = b.fpm_ac_code
    ,facmast c right outer join fstatus d on c.company = d.company
    but this is equivalent
    select a.company,b.fpm_ac_code from facmast a,fparty b,facmast c, fstatus d
    where a.company = b.company(+)
    and a.fac_ac_code = b.fpm_ac_code(+)
    and c.company = d.company(+)
    pls help me
    Siddharth singh

    I would transpose this statement...
    select a.company, b.fpm_ac_code
    from facmast a, fparty b, fstatus c
    where a.company = b.company(+)
    and a.fac_ac_code = b.fpm_ac_code(+)
    and a.company = c.company(+)
    into this...
    SELECT a.company, b.fpm_ac_code
    FROM facmast a
    LEFT OUTER JOIN fparty b
    ON a.company = b.company
    AND a.fac_ac_code = b.fpm_ac_code
    LEFT OUTER JOIN fstatus c
    ON a.company = c.company
    I think this may be closer to what you want.
    Remember, the (+) goes on the side that is deficient in information; but the LEFT or RIGHT keyword points to the table on the side of the JOIN clause (not the ON condition) from which you want information.
    Best!

  • SQL 92 Outer Join Syntax and Funtion.

    When i am trying to use {fn substring(..)} or {oj table} in sql query to make it database independent, oralce driver does not support this.
    Could any one explain the above issue?
    If so, How do i use it? Explain the syntax a bit.
    Thanks in Advance,
    Ramani.

    I should add that I have tried to change SQLServerPlatform to have shouldPrintOuterJoinInWhereClause() return "true". This embeds a "=*" in the join conditions in the WHERE clause.
    SQL Server 2000 still supports this syntax, but the "=*" isn't ALWAYS the correct operator. It is IMPORTANT to put the "*" on the correct side of the expression.
    TopLink always prints "=*", and it always puts it in the correct space, but the OPERATORS are not always in the correct order so you are creating a "left join" on the wrong table.
    So my other question, is it possible to FORCE TopLink to remember to put the outer join table in the RIGHT SIDE?
    Nate

  • ANSI 1999 Syntax and Query Optimization

    I am big fan of the new ANSI 1999 join syntax. I think it makes queries easier to code, understand and debug.
    However, do I become my own optimizer when I use it?
    What does the cost based optimizer still do for me (beyond selecting applicable indexes) when I use this syntax?
    regards,
    TT

    The CBO determines the driving table via the statistics:
    create table big_table as select * from dba_objects
    Table created.
    create table small_table as select * from user_objects
    where  rownum < 6
    Table created.
    analyze table big_table compute statistics
    Table analyzed.
    analyze table small_table compute statistics
    Table analyzed.
    select b.owner, s.object_name
    from   small_table s
    join   big_table b
        on b.object_id = s.object_id
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=54 Card=5 Bytes=125)
       1    0   HASH JOIN (Cost=54 Card=5 Bytes=125)
       2    1     TABLE ACCESS (FULL) OF 'SMALL_TABLE' (Cost=2 Card=5 Bytes=75)
       3    1     TABLE ACCESS (FULL) OF 'BIG_TABLE' (Cost=51 Card=37001 Bytes=370010)
    select b.owner, s.object_name
    from   big_table b
    join   small_table s
        on b.object_id = s.object_id
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=54 Card=5 Bytes=125)
       1    0   HASH JOIN (Cost=54 Card=5 Bytes=125)
       2    1     TABLE ACCESS (FULL) OF 'SMALL_TABLE' (Cost=2 Card=5 Bytes=75)
       3    1     TABLE ACCESS (FULL) OF 'BIG_TABLE' (Cost=51 Card=37001 Bytes=370010)Hmmm, the CBO didn't even bother with nested loops, it decided that a hash-join was best. I guess the driving table was not even a factor...

  • Bug in JOIN syntax? (oracle 9i)

    Hi,
    take these three tables:
    MASTER (id NUMBER, name VARCHAR2(10))
    DETAIL (id NUMBER, master_id NUMBER)
    SUBDETAIL (id NUMBER, detail_id NUMBER, name VARCHAR(10)
    When I perform this query:
    SELECT SUBDETAIL.id as did, MASTER.id as mid
    FROM SUBDETAIL
    JOIN DETAIL ON (SUBDETAIL.detail_id = DETAIL.id)
    JOIN MASTER ON (DETAIL.master_id = MASTER.id)
    WHERE
    name = 'joe';
    I would expect the parser to give me 'column ambiguously defined' (because the 'name' field from the whereclause is defined in both subdetail and master).
    However, it does not say that. Instead, it assumes that it should use the name field from master. This is confusing, as this could easily lead to mistakes (as it did in my application)
    Greetings,
    Ivo

    There seems to be a difference between the way Oracle resolves column names using the ANSI join syntax and Oracle's syntax. It appears that Oracle does not know about the columns, until it processes each join, and further, the last table joined seems to be sued to resolve nameing conflicts. Consider:
    SQL> SELECT * FROM master;
            ID NAME
             1 joe
    SQL> SELECT * FROM subdetail;
            ID  DETAIL_ID NAME
             1          2 fred
    SQL> SELECT * FROM detail;
            ID  MASTER_ID
             2          1
    SQL> SELECT subdetail.id AS did, master.id AS mid
      2  FROM subdetail
      3       JOIN detail ON (subdetail.detail_id = detail.id)
      4       JOIN master ON (detail.master_id = master.id)
      5  WHERE name = 'joe';
           DID        MID
             1          1
    SQL> SELECT subdetail.id AS did, master.id AS mid
      2  FROM subdetail
      3       JOIN detail ON (subdetail.detail_id = detail.id)
      4       JOIN master ON (detail.master_id = master.id)
      5  WHERE name = 'fred';
    no rows selected
    So, it is clearly going after master.name. However,
    SQL> SELECT subdetail.id AS did, master.id AS mid
      2  FROM detail
      3       JOIN master ON (master.id = master_id)
      4       JOIN subdetail ON (subdetail.detail_id = detail.id)
      5  WHERE name = 'joe'
    no rows selected
    But,
    SQL> SELECT subdetail.id AS did, master.id AS mid
      2  FROM detail
      3       JOIN subdetail ON (subdetail.detail_id = detail.id)
      4       JOIN master ON (master.id = master_id)
      5  WHERE name = 'joe'
           DID        MID
             1          1
    Old style syntax gives:
    SQL> SELECT subdetail.id AS did, master.id AS mid
      2  FROM subdetail, detail, master
      3  WHERE subdetail.detail_id = detail.id and
      4        detail.master_id = master.id and
      5        name = 'joe';
          name = 'joe'
    ERROR at line 5:
    ORA-00918: column ambiguously defined
    and note that
    SQL> SELECT subdetail.id AS did, master.id AS mid
      2  FROM subdetail
      3      JOIN master ON (detail.master_id = master.id)
      4      JOIN detail ON (subdetail.detail_id = detail.id)
      5  WHERE name = 'joe'
        JOIN master ON (detail.master_id = master.id)
    ERROR at line 3:
    ORA-00904: invalid column nameSo, in ANSI syntax, order matters, and whatever the syntax good testing matters.
    TTFN
    John

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

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

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

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

  • 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

  • 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

  • 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

  • Outer Join Syntax in sql2k to Oracle Migration

    All of my existing SQL Server 2000 code is using the (INNER, LEFT OUTER, RIGHT OUTER) JOIN syntax which according to Oracle SQL Reference (A90125-01) is supported. The migration workbench seems to want to convert this to the old style syntax of putting (+) in the where clause conditions. I am therefore getting lots of warnings telling me that "complex outer joins are not reliably supported". Is there a setting somewhere that will tell the migration workbench to maintain (subject to required conversion) the original syntax format.

    Hi Doug,
    The issue you report has been tackled in a recent internal build released by the OMWB team. OMWB version 9.2.0.1.6 which is freely downloadable on the http:\\mtg.ie.oracle.com site. As I've mentioned, this is an internal release and is therefore not supported - although it is very stable and has already been used by several internal customers. We expect to have a fully supported release of OMWB available on OTN in December.
    In version 9.2.0.1.6, there is an option in the "Parse Options" tab on the Stored Procedures property sheet called "Generate Oracle 8i Outer Joins" - this setting is switched off by default in this build and would therefore preserve your ANSI compliant joins by default. Switching the setting on causes the OMWB parser to generate the joins in the old (+) Oracle syntax standard.
    I hope this helps,
    Tom.

  • Configure "Query Builder" for Theta-Style Joins over ANSI-Style Joins

    Can SQL Developer be configured to auto generate theta-style joins instead of ANSI-style joins when building queries? This happens when I generate a query using the Query Builder and then switch over to the Worksheet tab to see the SQL code.
    Sample code:
    Theta-style join syntax uses commas to separate multiple table names and creates the joins in the Where clause:
    SELECT c.name
    FROM instructors i, courses c
    WHERE i.firstname = 'Mary' AND i.lastname = 'Williams'
    AND i.course_id = c.course_id;
    ANSI syntax uses the JOIN and ON keywords instead:
    SELECT c.name
    FROM instructors i JOIN courses c
    ON i.course_id = c.course_id
    WHERE i.firstname = 'Mary' AND i.lastname = 'Williams';

    Hi Wes,
    There is no preference for configuring this that I know of, but Query Builder is fairly clever about detecting your flavor of SQL from the worksheet then sticking with it. If you design it graphically, the default flavor is ANSI, but QB seems to respect any worksheet edits that switch it to another flavor. I wouldn't vouch for that absolutely, but perhaps it's behavior you can take advantage of.
    Regards,
    Gary
    SQL Developer Team

  • Request your expert opinions -- 9i join syntax?

    Are you who do SQL programming going to use the new 9i JOIN syntax? Is the old syntax (using the + sign) going to be depricated soon? What do you think? Why should I switch to the new format? I am wondering what others are doing or planning to do.
    Thank you very much for your time.

    Personally, I think the ANSI compliant syntax is clearer and easier to read. Also it has FULL OUTER which is something the old Oracle syntax doesn't support.
    However, I don't think (+) will be deprecated before 10i and I think it will remained suppported for the foreseeable future: there're just too many lines of SQL code out there using it!
    my tuppence halfpenny worth, APC

Maybe you are looking for

  • Change in Assignment Category gives error

    FRM-40735 POST- UPDATE trigger raised unhandled exception ORA- 01403 I am getting the above error when i am trying to change the Assignment Category field of an employee from Junior Staff to Senior Staff. Navigation People> Enter & Maintain> (B)Assig

  • How do I download my Camera to the ipad and then to iphoto on my G5?

    Lets say that I'm on vacation and the memory card on my camera is full. How do I download my camera to the ipad2? And then when I get home how do I transfer those same photos to iphoto on my G5 running Leopard? Thanks!

  • Airport Disk problems

    There seem to be a lot of threads going on about connectivity problems regarding disks connected to Airport Extreme base stations. This http://discussions.apple.com/thread.jspa?threadID=1155412 is probably the biggest. Since this really is a large is

  • Accurate preview of gradients in EPS objects

    I hope I can explain this properly... our company has been using a primarily Quark-based workflow for as long as I've been here. We would take individual layouts, save them as EPS, and then import them into a master layout (which was the size of our

  • Adding large amounts of data to multiple traces

    Hi, I have a CNiGraph object. I want to add a 100 traces (plots) with each 500.000pts, and later update with 50.000pts/sec for each trace. How can I do this? I tried and got a result of 45 seconds for 300pts/trace for 100 traces. I must be missing so