Oracle SQL / Ansi SQL

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

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

Similar Messages

  • Differences between ANSI SQL and Oracle 8/9

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

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

  • What is Difference between ANSI SQL and ORACLE SQL

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

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

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

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

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

  • Generate ANSI SQL with Oracle IKM

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

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

  • Help on - convert ansi sql to oracle sql

    hi gurus,
    i'm try'g to convert ansi sql to oracle sql.
    but i'm getting an error. can u please let me know, if i can convert it or is it better to use ansi sql!
    original code in ansi format::
    select distinct bfc.NBR_SEQ, bfc.IDN_ENTITY, bfc.CDE_TYPE_ENTITY, n.CDE_STATUS,
             gec.idn_group as idn_parent_id, bfc.IDN_FUNC_BUSS,
             case when bfc.CDE_TYPE_ENTITY = 'P'  OR bfc.CDE_TYPE_ENTITY = 'A' then
                PKG_FW_NVGTR.GET_NAM_PAGE(bfc.IDN_ENTITY)
              else
                PKG_FW_NVGTR.GET_NAM_GROUP(bfc.IDN_ENTITY)
             end as ENTITY_NAM,
             p.Category, p.Display_Txt, p.show_in_nav, p.page_uri
      from
        T_BUSS_FUNC_ENTITY_CREF bfc
        inner join t_buss_func bf on bfc.idn_func_buss = bf.idn_func_buss
        inner join t_entity_prog_cref epc on bfc.idn_entity = epc.idn_entity and bfc.cde_type_entity = epc.cde_type_entity
        left outer join t_page p on bfc.idn_entity = p.idn_page
        left outer join t_group_entity_cref gec on bfc.idn_entity = gec.idn_entity and bfc.cde_type_entity = gec.cde_type_entity
        left outer join t_nvgtr n on bfc.idn_entity = n.idn_entity and bfc.cde_type_entity = n.cde_type_entity
      where
        BF.nam_func_buss = 'CP' AND--P_NAM_FUNC_BUSS and
        epc.cde_program in
          ( select p.cde_program from t_program p where p.nam_program in (
              SELECT * FROM TABLE (CAST(PKG_FW_NVGTR.FN_GET_ARRAY_FROM_COMMA_LIST('LC', ',') AS TYP_ARRAY))))
      order by
        bfc.NBR_SEQ;tried to convert into oracle
    SELECT DISTINCT bfc.NBR_SEQ,
                 bfc.IDN_ENTITY,
                 bfc.CDE_TYPE_ENTITY,
                 n.CDE_STATUS,
                 gec.idn_group as idn_parent_id,
                 bfc.IDN_FUNC_BUSS,
                 case when bfc.CDE_TYPE_ENTITY = 'P'  OR bfc.CDE_TYPE_ENTITY = 'A' then
                             PKG_FW_NVGTR.GET_NAM_PAGE(bfc.IDN_ENTITY)
                           else
                             PKG_FW_NVGTR.GET_NAM_GROUP(bfc.IDN_ENTITY)
                 end as ENTITY_NAM,
                 p.Category,
                 p.Display_Txt,
                 p.show_in_nav,
                 p.page_uri
    FROM    T_BUSS_FUNC_ENTITY_CREF bfc,
                 T_BUSS_FUNC bf,
                 T_ENTITY_PROG_CREF epc,
                 T_PAGE p,
                 T_GROUP_ENTITY_CREF gec,
                 T_NVGTR n
    WHERE bfc.IDN_FUNC_BUSS = bf.IDN_FUNC_BUSS
    AND bfc.IDN_ENTITY = epc.IDN_ENTITY
    AND bfc.CDE_TYPE_ENTITY = epc.CDE_TYPE_ENTITY
    AND bfc.IDN_ENTITY(+) = p.IDN_PAGE
    AND bfc.IDN_ENTITY(+) = gec.IDN_ENTITY
    AND bfc.CDE_TYPE_ENTITY(+) = gec.CDE_TYPE_ENTITY
    AND bfc.IDN_ENTITY(+) = n.IDN_ENTITY
    AND bfc.CDE_TYPE_ENTITY(+) = n.CDE_TYPE_ENTITY
    AND BF.nam_func_buss = 'CP' AND--P_NAM_FUNC_BUSS and
        epc.cde_program in
          ( select p.cde_program from t_program p where p.nam_program in (
              SELECT * FROM TABLE (CAST(PKG_FW_NVGTR.FN_GET_ARRAY_FROM_COMMA_LIST('LC', ',') AS TYP_ARRAY))))
                   order by
                     bfc.NBR_SEQ;error is
    ORA-01417: a table may be outer joined to at most one other tableso how can i convert it?
    thanks

    user642856 wrote:
    explain plan for this select statement
    ID         PID       Operation                                                                                  Name                                                                Rows    Bytes    Cost     CPU Cost          IO Cost Temp space      IN-OUT  PQ Dist PStart   PStop
    0                      SELECT STATEMENT                                                                                                                                       10M                  1183M  570694 33G      567917                                                  
    1          0            SORT UNIQUE                                                                                                                                                            10M                  1183M  287940 17G      286502 2607M                                      
    2          1              HASH JOIN                                                                                                                                                   10M                  1216M  179       1G        84                                                          
    3          2                COLLECTION ITERATOR PICKLER FETCH   PKG_FW_NVGTR.FN_GET_ARRAY_FROM_COMMA_LIST                                                                                                                         
    4          2                HASH JOIN OUTER                                                                                                                         2693             299K     58         34M      55                                                          
    5          4                  HASH JOIN OUTER                                                                                                                                   37                     3959     11         24M      9                                                           
    6          5                    HASH JOIN OUTER                                                                                                                     37                         3663     10         18M      8                                                           
    7          6                      HASH JOIN                                                                                                                               37                         1147     7          12M      6                                                           
    8          7                        HASH JOIN                                                                                                                             59                         1180     5          6060823            4                                                           
    9          8                          NESTED LOOPS                                                                                                       2                      24                     3          15843   3                                                           
    10         9                            TABLE ACCESS BY INDEX ROWID  T_BUSS_FUNC             1                      6                      1             8341     1                                                           
    11         10                             INDEX UNIQUE SCAN                                UK_NAM_FUNC_BUSS 1                       0                      1050     0                                                           
    12         9                            TABLE ACCESS FULL                                             T_PROGRAM                2                      12             2          7501     2                                                           
    13         8                          INDEX FULL SCAN                            PK_T_ENTITY_PROG_CREF      59                     472       1             18921   1                                                           
    14         7                        TABLE ACCESS FULL                         T_BUSS_FUNC_ENTITY_CREF  37                     407       2             14891   2                                                           
    15         6                      TABLE ACCESS FULL                           T_PAGE                                                           26                     1768     2          14141   2                                                           
    16         5                    INDEX FULL SCAN                                              UK_UNIQUE_GROUP_DEPENDENT 26              208             1          12321   1                                                           
    17         4                  TABLE ACCESS FULL                                           T_NVGTR                                                          6986             47K      46         3179613            46                                                           as you can see.. cpu cost is in 33G..
    is there any better way?
    thanksCan you run this in a session please:
    ALTER SESSION set optimizer_dynamic_sampling = 4;Then run an explain plan again.
    And you have a function in there - PKG_FW_NVGTR.FN_GET_ARRAY_FROM_COMMA_LIST - which isn't helping things.

  • Converting oracle join to Ansi sql join

    Hi Guys,
    I am new to SQL and trying to convert the following Oracle query (joins) into ANSI sql joins...Can someone please help me?
    SELECT M.EXTERNALCODE, M.NAME AS MNAME, SC.BIRIM, SM.TRANSACTIONDATE, SMD.AMOUNT,
    SMD.UNITPRICE, SM.ID AS SMID, SMD.ID AS SMDID, F.NAME AS FNAME,
    IFNULL (SMD.AMOUNT, 0, SMD.AMOUNT) * IFNULL (SMD.UNITPRICE, 0, SMD.UNITPRICE) AS TOTALPRICE, SMD.AMOUNT AS RECEIVED_QUANTITY,
    PD.ORDERID, PD.AMOUNT QUANTITY, PO.PROCESSDATE
    FROM STOCKMAINTRANSACTION SM,
    STOCKMAINTRANSACTIONDETAIL SMD,
    MATERIAL M,
    STOCKCARD SC,
    FVSTOCK FVS,
    FIRM F,
    PURCHASEORDER PO,
    PURCHASEORDERDETAIL PD,
    PURCHASEORDERDETAILSUPPLIED PDS
    WHERE SM.ID = SMD.MAINTRANSACTIONID
    AND SMD.MATERIALID = M.ID
    AND SMD.STOCKCARDID = SC.ID
    AND SM.PROPREF = FVS.RECORDID(+)
    AND FVS.FIELDID(+) = 2559
    AND FVS.FLEVEL(+) = 'F'
    AND F.ID(+) = SUBSTR (FVS.FVALUE, 1, 9)
    AND SM.TRANSDEFID in (999,2329,2344,2370,150000903,150005362)
    AND SMD.CANCELLED = 0
    AND SMD.STOCKUPDATED = 1
    AND SMD.ID = PDS.STOCKMAINTRANSACTIONDETAILID
    AND PDS.ORDERDETAILID = PD.ORDERDETAILID
    AND PO.ORDERID = PD.ORDERID
    AND (M.ID = {@MATERIALID@} OR {@MATERIALID@} = 0)
    AND (SM.STOREID = {@STOREID@} OR {@STOREID@} = 0)
    AND (F.ID = {@SUPPLIERID@} OR {@SUPPLIERID@} = 0)
    AND SM.TRANSACTIONDATE BETWEEN {@STARTDATE@} AND {@ENDDATE@}
    ORDER BY F.NAME, M.EXTERNALCODE, SM.TRANSACTIONDATE
    Really appreciate the help!
    Thanks.

    Hi,
    Welcome to the forum!
    To convert to ANSI syntax, replace join conditions in the WHERE clause
    FROM           x
    ,             y
    WHERE         x.x1  = y.y1
    AND           x.x2  = y.y2with ON conditions in the FROM clause:
    FROM           x
    JOIN             y   ON    x.x1  = y.y1
                             AND   x.x2  = y.y2In inner joins, conditions that do not reference 2 tables are not really join conditions, so it doesn't matter if they are in the FROM clause or in the WHERE clause.
    In your case
    SM.TRANSDEFID in (999,2329,2344,2370,150000903,150005362)could be part of a join condition involving sm, or it could be in the WHERE clause. Most people find it clearer if 1-table conditions like this are in the WHERE clause.
    Again, this only applies to inner joins. For outer joins, all conditions that apply to a table that may lack matching rows must be included in the FROM clause, like this:
    LEFT OUTER JOIN  fvstock   fvs  ON   sm.propref       = fvs.recordid
                                    AND  fvs.fieldid  = 2559
                        AND  fvs.flevel   = 'F'Try it.
    If you have trouble, post your best attempt, along with CREATE TABLE and INSERT statements for a little sample data from all the tables involved, and the results you want from that data. Simplify the problem. Post only the tables and columns that you don't know how to handle.
    See the forum FAQ {message:id=9360002}
    user8428528 wrote:
    AND (M.ID = {@MATERIALID@} OR {@MATERIALID@} = 0)
    AND (SM.STOREID = {@STOREID@} OR {@STOREID@} = 0)
    AND (F.ID = {@SUPPLIERID@} OR {@SUPPLIERID@} = 0)
    AND SM.TRANSACTIONDATE BETWEEN {@STARTDATE@} AND {@ENDDATE@}This is not valid Oracle SQL. Is {@MATERIALID@} some kind of variable?

  • ANSI SQL to Oracle Old SQL conversion

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

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

  • ANSI SQL 92 SYNTAX OUTER JOIN PERFORMANCE ISSUE

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

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

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

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

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

  • OWB 10.2.0.4 ANSI SQL join problem

    Hi
    Its seams to me, that in OWB 10.2.0.4 there is something broken with ANSI SQL joins and instead of ANSI joins there is used oracle SQL joins only. Maybe someone can point some solutions? I can’t rewrite all mappings with union and other operators. And manually pl/sql editing also would be big problem.

    "Am I correct in assuming you did not code ANSI joins?" -> yes, i am coding Oracle SQL joins and with this option just generating ANSI joins.
    With ANSI SQL join you can use OR and IN operands (and code looks more readable).
    It is question of performance (so for example 80% of dataset you can join by one column other 15% by second etc ..). So this all can be rewritten also in Split->join->union all, but if you have several such joins, this will be painfully.

  • 9i: JDBC-driver for SQL ANSI 92 Standard

    Does anyone know when the Oracle JDBC driver will support the SQL ANSI 92 Standard for joins?
    If not, are there any workarounds?

    Oracle 9i supports this syntax, so anything that connects to a 9i database will be able to use it. Unless the driver is reqriting the query, which I doubt, you should be able to use any client API with a 9i server.
    Justin

  • Iso/ansi sql-99 query

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

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

  • How to resolve most of the Oracle SQL , PL/SQL Performance issues with help of quick Checklist/guidelines ?

    Please go thru below important checklist/guidelines to identify issue in any Perforamnce issue and resolution in no time.
    Checklist for Quick Performance  problem Resolution
    ·         get trace, code and other information for given PE case
              - Latest Code from Production env
              - Trace (sql queries, statistics, row source operations with row count, explain plan, all wait events)
              - Program parameters & their frequently used values
              - Run Frequency of the program
              - existing Run-time/response time in Production
              - Business Purpose
    ·         Identify most time consuming SQL taking more than 60 % of program time using Trace & Code analysis
    ·         Check all mandatory parameters/bind variables are directly mapped to index columns of large transaction tables without any functions
    ·         Identify most time consuming operation(s) using Row Source Operation section
    ·         Study program parameter input directly mapped to SQL
    ·         Identify all Input bind parameters being used to SQL
    ·         Is SQL query returning large records for given inputs
    ·         what are the large tables and their respective columns being used to mapped with input parameters
    ·         which operation is scanning highest number of records in Row Source operation/Explain Plan
    ·         Is Oracle Cost Based Optimizer using right Driving table for given SQL ?
    ·         Check the time consuming index on large table and measure Index Selectivity
    ·         Study Where clause for input parameters mapped to tables and their columns to find the correct/optimal usage of index
    ·         Is correct index being used for all large tables?
    ·         Is there any Full Table Scan on Large tables ?
    ·         Is there any unwanted Table being used in SQL ?
    ·         Evaluate Join condition on Large tables and their columns
    ·         Is FTS on large table b'cos of usage of non index columns
    ·         Is there any implicit or explicit conversion causing index not getting used ?
    ·         Statistics of all large tables are upto date ?
    Quick Resolution tips
    1) Use Bulk Processing feature BULK COLLECT with LIMIT and FOR ALL for DML instead of row by row processing
    2) Use Data Caching Technique/Options to cache static data
    3) Use Pipe Line Table Functions whenever possible
    4) Use Global Temporary Table, Materialized view to process complex records
    5) Try avoiding multiple network trips for every row between two database using dblink, Use Global temporary table or set operator to reduce network trip
    6) Use EXTERNAL Table to build interface rather then creating custom table and program to Load and validate the data
    7) Understand Oracle's Cost based Optimizer and Tune most expensive SQL queries with help of Explain plan
    8) Follow Oracle PL/SQL Best Practices
    9) Review tables and their indexes being used in the SQL queries and avoid unnecessary Table scanning
    10) Avoid costly Full Table Scan on Big Transaction tables with Huge data volume,
    11) Use appropriate filtration condition on index columns of seeded Oracle tables directly mapped to program parameters
    12) Review Join condition on existing query explain plan
    13) Use Oracle hint to guide Oracle Cost based optimizer to choose best plan for your custom queries
    14) Avoid applying SQL functions on index columns
    15) Use appropriate hint to guide Oracle CBO to choose best plan to reduce response time
    Thanks
    Praful

    I understand you were trying to post something helpful to people, but sorry, this list is appalling.
    1) Use Bulk Processing feature BULK COLLECT with LIMIT and FOR ALL for DML instead of row by row processing
    No, use pure SQL.
    2) Use Data Caching Technique/Options to cache static data
    No, use pure SQL, and the database and operating system will handle caching.
    3) Use Pipe Line Table Functions whenever possible
    No, use pure SQL
    4) Use Global Temporary Table, Materialized view to process complex records
    No, use pure SQL
    5) Try avoiding multiple network trips for every row between two database using dblink, Use Global temporary table or set operator to reduce network trip
    No, use pure SQL
    6) Use EXTERNAL Table to build interface rather then creating custom table and program to Load and validate the data
    Makes no sense.
    7) Understand Oracle's Cost based Optimizer and Tune most expensive SQL queries with help of Explain plan
    What about using the execution trace?
    8) Follow Oracle PL/SQL Best Practices
    Which are?
    9) Review tables and their indexes being used in the SQL queries and avoid unnecessary Table scanning
    You mean design your database and queries properly?  And table scanning is not always bad.
    10) Avoid costly Full Table Scan on Big Transaction tables with Huge data volume,
    It depends if that is necessary or not.
    11) Use appropriate filtration condition on index columns of seeded Oracle tables directly mapped to program parameters
    No, consider that too many indexes can have an impact on overall performance and can prevent the CBO from picking the best plan.  There's far more to creating indexes than just picking every column that people are likely to search on; you have to consider the cardinality and selectivity of data, as well as the volumes of data being searched and the most common search requirements.
    12) Review Join condition on existing query explain plan
    Well, if you don't have your join conditions right then your query won't work, so that's obvious.
    13) Use Oracle hint to guide Oracle Cost based optimizer to choose best plan for your custom queries
    No.  Oracle recommends you do not use hints for query optimization (it says so in the documentation).  Only certain hints such as APPEND etc. which are more related to certain operations such as inserting data etc. are acceptable in general.  Oracle recommends you use the query optimization tools to help optimize your queries rather than use hints.
    14) Avoid applying SQL functions on index columns
    Why?  If there's a need for a function based index, then it should be used.
    15) Use appropriate hint to guide Oracle CBO to choose best plan to reduce response time
    See 13.
    In short, there are no silver bullets for dealing with performance.  Each situation is different and needs to be evaluated on its own merits.

  • Unable to configure Oracle Publisher in SQL SERVER 2008 R2

    Hi, All,
    I am trying to talk to my Oracle database from SQL server. I already had Oracle Client 11g installed in my SQL server. 
    Following the guidance in the technet on configuring the Distributer successfully. I now trying to configure the Publisher, by choosing "Adding Oracle Publisher" option. Then it prompt for the user id & password, I have enter the login (which
    is replication user id created in Oracle). I encounter following error msg:
    TITLE: Distributor Properties
    Oracle server instance 'ssluat' cannot be enabled as a Publisher because of the following error:
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600.1&EvtSrc=Microsoft.SqlServer.Management.UI.ConfigureWizardErrorSR&EvtID=OraclePublisherValidateFailed&LinkId=20476
    Quote:
    ADDITIONAL INFORMATION:
    Unable to run SQL*PLUS. Make certain that a current version of the Oracle client code is installed at the distributor. For addition information, see SQL Server Error 21617 in Troubleshooting Oracle Publishers in SQL Server Books Online. (Microsoft SQL Server,
    Error: 21617)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600&EvtSrc=MSSQLServer&EvtID=21617&LinkId=20476
    Unquote
    In fact  I can run SQL*PLus from my c:\drive command prompt and the Path in Envinronment variable has set to "c:\app\product\11.2.0\client_1\bin". So I don't know why thing msg prompt?
    I have search the guideline on this error in Technet and do what I can to troubleshoot but still got error.
    Kindly pls help me.
    Thank you.
    Avelyn

    1.Make certain that a current version of the oracle client code is installed at the distributor”, please install corresponding version of Oracle
    Client tools on Distributor Box
    2.Are you able to connect to your Oracle server from the Distributor Box?if so,Distributor
    box needs to have Oracle client tools installed on it before you can setup replication , I hope you have installed the Oracle client tools on Distributor Box. If yes, check if using SQLPlus you can connect manually to Oracle server or not from your Distributor
    Box.
    Moreover,Please refer the below
    Before attempting to configure the Oracle Publisher, SQL Server verifies that SQL*PLUS is accessible through the system path on the Distributor. If SQL*PLUS cannot be loaded, the following error message is shown:
    "Unable to run SQL*PLUS. Make certain that a current version of the Oracle client code is installed at the distributor."
    Try to locate SQL*PLUS on the Distributor. For an Oracle 10g client install, the name of this executable is sqlplus.exe. It is typically installed in %ORACLE_HOME%/bin. To verify that the path of SQL*PLUS appears in the system path, examine the value of the
    system variable Path:
    Right-click My Computer, and then click Properties.
    Click the Advanced tab, and then click Environment variables.
    In the Environment Variables dialog box, in the System variables list, select the Path variable,
    and then click Edit.
    In the Edit System Variable dialog box: if the path to the folder that contains sqlplus.exe is not present in the Variable
    value text box, edit the string to include it.
    Click OK on each open dialog box to exit and save changes.

Maybe you are looking for

  • Where can I find information about creative/artistic software for my Mac?

    I write (mostly children's plays) so I need to find out exactly what kinds of software are available to me for scripts, film, published material, etc. I am planning to rewrite a script which has been produced on stage several times into an animated f

  • BPC 7MS new features and advantages

    Hi I got the info that the following features cast in BPC 7MS version: Management console - support for seasonality in Insight - multiple hierarchies in time dimension - Load Runner test tool certification - MS Vista support (only for 32 bit machines

  • Document preview shows EDIT option even if someone does not have edit rights

    From what I can see, in the document preview panel in search results one of the options says "EDIT" even though the searcher only has read rights. Is this correct? If so is there a way of changing it so that it says "OPEN" if the document is read-onl

  • How do I set the content type ?

    Hi I have to upload a file from my Java Application to a remote servlet. I have used the HTTPConnection class to connect to the remote servlet and made it call the POST method explicitly. How do I set the content type of the file I am uploading from

  • Graphic Frame can not be renamed

    FM-11 and FM-12: In the Object Properties there is no more a field Name. Hence a graphic frame on the reference pages can not be checked for its name or the name can not be edited. I have filed this as a bug. The dialogue in FM-12 and FM-11: In FM-10