ORA-32036 unsupported case for inlining of query name in WITH clause

I have a query with a WITH clause. In the WITH clause I am using the TABLE command to pull multiple records from a PL/SQL function in the FROM clause:
WITH select_a AS
(select x.col1,
x.col2
from A,
TABLE(schema1.function1) x
where ...)
select ...
from ...;
The query is returning 32036 oracle error. Any thoughts on why I get this error? Is it valid to use the TABLE command with a function in the WITH clause?

Is it valid to use the TABLE command with a function in the WITH clause?Something else must be going on: Even on my old 9i I can use WITH together with TABLE:
SQL> select * from v$version where rownum = 1
BANNER                                                         
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
1 row selected.
SQL> create or replace function f1 (deptno int) return sys.dbms_debug_vc2coll
as
begin
return sys.dbms_debug_vc2coll(deptno);
end;
Function created.
SQL> with t as (
select dept.* from dept, table (f1(deptno)) where column_value = deptno
select * from t
    DEPTNO DNAME          LOC         
        10 ACCOUNTING     NEW YORK    
        20 RESEARCH       DALLAS      
        30 SALES          CHICAGO     
        40 OPERATIONS     BOSTON      
4 rows selected.

Similar Messages

  • ORA-32031: illegal reference of a query name in WITH clause

    Oracle tutorial : http://www.oracle.com/technology/pub/articles/hartley-recursive.html#4
    When Executing this Query 6: Using a Recursive WITH Clause
    WITH C (CNO, PCNO, CNAME) AS
    (SELECT CNO, PCNO, CNAME -- initialization subquery
    FROM COURSEX
    WHERE CNO = 'C22' -- seed
    UNION ALL
    SELECT X.CNO, X.PCNO, X.CNAME -- recursive subquery
    FROM C, COURSEX X
    WHERE C.PCNO = X.CNO)
    SELECT CNO, PCNO, CNAME
    FROM C;
    Error: ORA-32031: illegal reference of a query name in WITH clause
    kindly suggest what need to do in case of recursion using subquery

    SCOTT@orcl> ed
    Wrote file afiedt.buf
      1  with c as
      2  (
      3  select empno,ename from emp
      4  where deptno=20
      5  union all
      6  select c.empno,c.ename from emp c
      7  where c.deptno=30
      8  )
      9* select * from c
    SCOTT@orcl> /
         EMPNO ENAME
          7566 xx
          7788 xx
          7876 xx
          7902 xx
          7499 xx
          7521 xx
          7654 xx
          7698 xx
          7844 xx
          7900 xx
    10 rows selected.
    SCOTT@orcl> ed
    Wrote file afiedt.buf
      1  with emp as
      2  (
      3  select empno,ename from emp
      4  where deptno=20
      5  union all
      6  select c.empno,c.ename from emp c
      7  where c.deptno=30
      8  )
      9* select * from emp
    SCOTT@orcl> /
    select empno,ename from emp
    ERROR at line 3:
    ORA-32031: illegal reference of a query name in WITH clause
    SCOTT@orcl>You can not use the same table name alongwith WITH clause's cursor name. See as above if i says with C as... its works; but if i says with emp as... it returned ora-32031, because it is the name of table.
    HTH
    Girish Sharma

  • No authorization for the component (query name)!

    Hello all,
    when i am publishing the query in web, the following error message is displayed!
    "No authorization for the component (query name)!"
    i had installed and configured everything here, so the person responsible for authorization is none other than me. what i shud do now? shud i add any other authorization profile to the username created? or still any configuartion is required?
    please let me know!
    Thanks,
    Ravi

    Hi ARK,
    thanks for the info.
    i had assigned SAP_ALL and SAP_NEW profiles to the user.
    let me say clearly that when i am executing the Query in the designer it is working fine,no issues in Bex browser too. but when i want to publish safely exexuted query in web (clicking the button publish the query in web) i am getting the above mentioned error!
    do suggest me what is the authorization profile that is needed to serve my purpose?
    hope this time i am clear!
    Ravi

  • Indexes for group by query on table with 5million records

    Hi,
    Here is my query which is taking ages to run :
         SELECT approved.budgetReferenceno
                   , approved.projects
                   , approved.allocations
                   , rptgen4
                         , financialyear
                   , cashclass
                   , SUM(nvl(approved.FullYear,0)) as FullYear
              FROM   approved
              JOIN   rpt_entity ON rpt_entity.level0 = approved.entity
              JOIN   cashclasses     ON accountcode    = approved.account
        where budgetreferenceno = refno    
        and
            entity in ( 
               (select Level0 from rpt_entity   where   
               (   entityparent in (select * from table(split(userid)))    or   rptgen5 in (select * from table(split(userid)))   )   ) 
         and
           ccs in (select level0 from rpt_ccs where rptgen4 in (select * from table(split(userid)))) or
           ccs in (select level0 from rpt_ccs where rptgen5 in (select * from table(split(userid)))) or
           ccs in (select level0 from rpt_ccs where rptgen6 in (select * from table(split(userid)))) or
           ccs in (select level0 from rpt_ccs where rptgen7 in (select * from table(split(userid))) ) or
           ccs in (select distinct(substr(column_value,2,length(column_value)-2)) from table(split_comma(userid)) )
              GROUP BY approved.budgetReferenceno
                   , approved.projects
                   , approved.allocations
                   , rptgen4
                         , financialyear
                   , cashclass
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 4074481161
    | Id  | Operation                                | Name            | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                         |                 | 31234 |  3660K|       | 86141   (1)| 00:17:14 |
    |   1 |  HASH GROUP BY                           |                 | 31234 |  3660K|    17M| 86141   (1)| 00:17:14 |
    |*  2 |   FILTER                                 |                 |       |       |       |            |          |
    |*  3 |    HASH JOIN                             |                 |   138K|    15M|       | 82427   (1)| 00:16:30 |
    |   4 |     TABLE ACCESS FULL                    | CASHCLASSES     |  2875 | 48875 |       |     5   (0)| 00:00:01 |
    |*  5 |     HASH JOIN                            |                 |   138K|    13M|       | 82420   (1)| 00:16:30 |
    PLAN_TABLE_OUTPUT
    |   6 |      TABLE ACCESS FULL                   | RPT_entity  |   725 | 10875 |       |    11   (0)| 00:00:01 |
    |*  7 |      HASH JOIN RIGHT SEMI                |                 |   138K|    11M|       | 82408   (1)| 00:16:29 |
    |   8 |       VIEW                               | VW_NSO_1        |    71 |   568 |       |    11   (0)| 00:00:01 |
    |*  9 |        FILTER                            |                 |       |       |       |            |          |
    |  10 |         TABLE ACCESS FULL                | RPT_entity  |   725 | 17400 |       |    11   (0)| 00:00:01 |
    |* 11 |         COLLECTION ITERATOR PICKLER FETCH| SPLIT           |       |       |       |            |          |
    |* 12 |         COLLECTION ITERATOR PICKLER FETCH| SPLIT           |       |       |       |            |          |
    |* 13 |       TABLE ACCESS FULL                  | approved        |  1170K|    89M|       | 82389   (1)| 00:16:29 |
    |  14 |    NESTED LOOPS                          |                 |     1 |    18 |       |    46   (0)| 00:00:01 |
    |  15 |     COLLECTION ITERATOR PICKLER FETCH    | SPLIT           |       |       |       |            |          |
    |* 16 |     INDEX RANGE SCAN                     | CC_INDEX1       |     1 |    16 |       |     1   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |  17 |    NESTED LOOPS                          |                 |     2 |    46 |       |    51   (2)| 00:00:01 |
    |* 18 |     INDEX FAST FULL SCAN                 | CC_INDEX2       |     1 |    21 |       |    46   (3)| 00:00:01 |
    |* 19 |     COLLECTION ITERATOR PICKLER FETCH    | SPLIT           |       |       |       |            |          |
    |  20 |    NESTED LOOPS                          |                 |     1 |    24 |       |    52   (0)| 00:00:01 |
    |  21 |     TABLE ACCESS BY INDEX ROWID          | RPT_ccs |     1 |    22 |       |    46   (0)| 00:00:01 |
    |* 22 |      INDEX SKIP SCAN                     | CC_INDEX1       |     1 |       |       |    45   (0)| 00:00:01 |
    |* 23 |     COLLECTION ITERATOR PICKLER FETCH    | SPLIT           |       |       |       |            |          |
    |  24 |    NESTED LOOPS                          |                 |     2 |    50 |       |    60   (0)| 00:00:01 |
    |  25 |     TABLE ACCESS BY INDEX ROWID          | RPT_ccs |     1 |    23 |       |    46   (0)| 00:00:01 |
    |* 26 |      INDEX SKIP SCAN                     | CC_INDEX1       |     1 |       |       |    45   (0)| 00:00:01 |
    |* 27 |     COLLECTION ITERATOR PICKLER FETCH    | SPLIT           |       |       |       |            |          |
    PLAN_TABLE_OUTPUT
    |* 28 |    COLLECTION ITERATOR PICKLER FETCH     | SPLIT_COMMA     |       |       |       |            |          |
    Predicate Information (identified by operation id):
       2 - filter( EXISTS (SELECT 0 FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE
                  "LEVEL0"=:B1 AND "RPTGEN4"=VALUE(KOKBF$)) OR  EXISTS (SELECT 0 FROM "RPT_ccs"
                  "RPT_ccs",TABLE() "KOKBF$" WHERE "RPTGEN5"=VALUE(KOKBF$) AND "LEVEL0"=:B2) OR  EXISTS (SELECT 0
                  FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE "RPTGEN6"=VALUE(KOKBF$) AND "LEVEL0"=:B3)
                  OR  EXISTS (SELECT 0 FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE
    PLAN_TABLE_OUTPUT
                  "RPTGEN7"=VALUE(KOKBF$) AND "LEVEL0"=:B4) OR  EXISTS (SELECT 0 FROM TABLE() "KOKBF$" WHERE
                  SUBSTR(VALUE(KOKBF$),2,LENGTH(VALUE(KOKBF$))-2)=:B5))
       3 - access("ACCOUNTCODE"="approved"."ACCOUNT")
       5 - access("RPT_entity"."LEVEL0"="approved"."entity")
       7 - access("approved"."entity"="LEVEL0")
       9 - filter( EXISTS (SELECT 0 FROM TABLE() "KOKBF$" WHERE VALUE(KOKBF$)=:B1) OR  EXISTS (SELECT 0 FROM
                  TABLE() "KOKBF$" WHERE VALUE(KOKBF$)=:B2))
      11 - filter(VALUE(KOKBF$)=:B1)
      12 - filter(VALUE(KOKBF$)=:B1)
      13 - filter("approved"."BUDGETREFERENCENO"='BASE')
      16 - access("RPTGEN4"=VALUE(KOKBF$) AND "LEVEL0"=:B1)
    PLAN_TABLE_OUTPUT
      18 - filter("LEVEL0"=:B1)
      19 - filter("RPTGEN5"=VALUE(KOKBF$))
      22 - access("LEVEL0"=:B1)
           filter("LEVEL0"=:B1)
      23 - filter("RPTGEN6"=VALUE(KOKBF$))
      26 - access("LEVEL0"=:B1)
           filter("LEVEL0"=:B1)
      27 - filter("RPTGEN7"=VALUE(KOKBF$))
      28 - filter(SUBSTR(VALUE(KOKBF$),2,LENGTH(VALUE(KOKBF$))-2)=:B1)
    64 rows selected.
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionThe table has 28 columns none indexed the columns mentioned here have non unique values.
    The table approved has more than 10million records and the query is taking a huge time.
    The query first tries to restrict the search to only valid entities and cc (already indexed and working fine).
    The cardinality of allocations, projects is around 1000, entity is 3000, and cc is around 50,000, reference number = 2000, financialyear = 4
    Please suggest which index would be best to use on these columns given that there will no updations but frequent insertions.
    If nothing else works than I will need to change it to pre aggregated data for overnight run .
    Thanks,
    Neetesh
    Edited by: user13312817 on Nov 16, 2011 11:05 AM
    Edited by: user13312817 on Nov 16, 2011 11:36 AM
    Edited by: user13312817 on Nov 16, 2011 11:38 AM
    Edited by: user13312817 on Nov 16, 2011 12:02 PM

    Hello Adam,
    Tried this but still not much of a difference.
    create index test_index on approved (budgetreferenceno,projects,allocations,financialyear,entity,ccs,FullYear) compress 6;
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2463060356
    | Id  | Operation                               | Name            | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                        |                 | 25030 |  4644K|       | 70852   (1)| 00:14:11 |
    |   1 |  TABLE ACCESS BY INDEX ROWID            | FEGEN4          |     1 |    13 |       |     2   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN                     | INDEX1          |     1 |       |       |     1   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS BY INDEX ROWID            | CASHCLASSES     |     1 |    17 |       |     2   (0)| 00:00:01 |
    |*  4 |   INDEX UNIQUE SCAN                     | CASHCLASSES_PK  |     1 |       |       |     1   (0)| 00:00:01 |
    |   5 |  HASH GROUP BY                          |                 | 25030 |  4644K|    21M| 70852   (1)| 00:14:11 |
    PLAN_TABLE_OUTPUT
    |   6 |   VIEW                                  |                 |   109K|    19M|       | 68578   (1)| 00:13:43 |
    |*  7 |    FILTER                               |                 |       |       |       |            |          |
    |*  8 |     HASH JOIN RIGHT SEMI                |                 |   484K|    99M|       | 68578   (1)| 00:13:43 |
    |   9 |      VIEW                               | VW_NSO_1        |    71 |  7242 |       |    11   (0)| 00:00:01 |
    |* 10 |       FILTER                            |                 |       |       |       |            |          |
    |  11 |        TABLE ACCESS FULL                | RPT_entity  |   725 | 17400 |       |    11   (0)| 00:00:01 |
    |* 12 |        COLLECTION ITERATOR PICKLER FETCH| SPLIT           |       |       |       |            |          |
    |* 13 |        COLLECTION ITERATOR PICKLER FETCH| SPLIT           |       |       |       |            |          |
    |* 14 |      TABLE ACCESS FULL                  | approved         |   982K|   106M|       | 68560   (1)| 00:13:43 |
    |  15 |     NESTED LOOPS                        |                 |     1 |    18 |       |    46   (0)| 00:00:01 |
    |  16 |      COLLECTION ITERATOR PICKLER FETCH  | SPLIT           |       |       |       |            |          |
    PLAN_TABLE_OUTPUT
    |* 17 |      INDEX RANGE SCAN                   | CC_INDEX1       |     1 |    16 |       |     1   (0)| 00:00:01 |
    |  18 |     NESTED LOOPS                        |                 |     2 |    46 |       |    51   (2)| 00:00:01 |
    |* 19 |      INDEX FAST FULL SCAN               | CC_INDEX2       |     1 |    21 |       |    46   (3)| 00:00:01 |
    |* 20 |      COLLECTION ITERATOR PICKLER FETCH  | SPLIT           |       |       |       |            |          |
    |  21 |     NESTED LOOPS                        |                 |     1 |    24 |       |    52   (0)| 00:00:01 |
    |  22 |      TABLE ACCESS BY INDEX ROWID        | RPT_ccs |     1 |    22 |       |    46   (0)| 00:00:01 |
    |* 23 |       INDEX SKIP SCAN                   | CC_INDEX1       |     1 |       |       |    45   (0)| 00:00:01 |
    |* 24 |      COLLECTION ITERATOR PICKLER FETCH  | SPLIT           |       |       |       |            |          |
    |  25 |     NESTED LOOPS                        |                 |     2 |    50 |       |    60   (0)| 00:00:01 |
    |  26 |      TABLE ACCESS BY INDEX ROWID        | RPT_ccs |     1 |    23 |       |    46   (0)| 00:00:01 |
    |* 27 |       INDEX SKIP SCAN                   | CC_INDEX1       |     1 |       |       |    45   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 28 |      COLLECTION ITERATOR PICKLER FETCH  | SPLIT           |       |       |       |            |          |
    |* 29 |     COLLECTION ITERATOR PICKLER FETCH   | SPLIT_COMMA     |       |       |       |            |          |
    Predicate Information (identified by operation id):
       2 - access("LEVEL0"=:B1)
       4 - access("ACCOUNTCODE"=:B1)
       7 - filter( EXISTS (SELECT 0 FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE
                  "LEVEL0"=:B1 AND "RPTGEN4"=VALUE(KOKBF$)) OR  EXISTS (SELECT 0 FROM "RPT_ccs"
    PLAN_TABLE_OUTPUT
                  "RPT_ccs",TABLE() "KOKBF$" WHERE "RPTGEN5"=VALUE(KOKBF$) AND "LEVEL0"=:B2) OR  EXISTS (SELECT 0
                  FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE "RPTGEN6"=VALUE(KOKBF$) AND "LEVEL0"=:B3)
                  OR  EXISTS (SELECT 0 FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE
                  "RPTGEN7"=VALUE(KOKBF$) AND "LEVEL0"=:B4) OR  EXISTS (SELECT 0 FROM TABLE() "KOKBF$" WHERE
                  SUBSTR(VALUE(KOKBF$),2,LENGTH(VALUE(KOKBF$))-2)=:B5))
       8 - access("entity"="LEVEL0")
      10 - filter( EXISTS (SELECT 0 FROM TABLE() "KOKBF$" WHERE VALUE(KOKBF$)=:B1) OR  EXISTS (SELECT 0 FROM
                  TABLE() "KOKBF$" WHERE VALUE(KOKBF$)=:B2))
      12 - filter(VALUE(KOKBF$)=:B1)
      13 - filter(VALUE(KOKBF$)=:B1)
      14 - filter("BUDGETREFERENCENO"='BASE')
    PLAN_TABLE_OUTPUT
      17 - access("RPTGEN4"=VALUE(KOKBF$) AND "LEVEL0"=:B1)
      19 - filter("LEVEL0"=:B1)
      20 - filter("RPTGEN5"=VALUE(KOKBF$))
      23 - access("LEVEL0"=:B1)
           filter("LEVEL0"=:B1)
      24 - filter("RPTGEN6"=VALUE(KOKBF$))
      27 - access("LEVEL0"=:B1)
           filter("LEVEL0"=:B1)
      28 - filter("RPTGEN7"=VALUE(KOKBF$))
      29 - filter(SUBSTR(VALUE(KOKBF$),2,LENGTH(VALUE(KOKBF$))-2)=:B1)
    PLAN_TABLE_OUTPUT
    Note
       - dynamic sampling used for this statement
    69 rows selected.Thanks,
    Neetesh
    Edited by: user13312817 on Nov 17, 2011 7:04 AM

  • Generating mixed case for table and column names

    I trying to get table definition from Oracle 9i database into my toplink workbench
    (version 9.0.3), the column names and table names are capitilized by
    default, how do I change this to be mixed case? Thanks

    I'm not sure why you want them changed. The Oracle database by default is case insensitive, which in essence means it converts everything to upper case when a case is not specified (which can be done by wrapping it in quotes). Unfortunately, Java strings are case sensitive. This means that if you try searching resultsets for "TableName" when the database driver is returning "TABLENAME", you will run into problems. It is probably better to have your project match your database as closely as possible to avoid any issues later on.
    That said, I don't know of a way to automatically have the workbench use mixed case names - it uses the strings as they are returned from the database. I believe you will need to manually change the table names if you want them to be different than what you have imported.
    Best Regards,
    Chris

  • Best protective cases for bare internal hard disks used with drive dock?

    I've been noticing that my external, powered hard drive enclosures are taking too much space; plus I think I can save money by plugging internal hard disks into a drive dock such as http://www.newertech.com/products/voyagerq.php , then connecting that via FireWire 800 to my Mac Pro.
    However, I don't want to leave them exposed when not active. I've searched around and found several options like silicone holders and WiebeTech's VHS-esque boxes, but not a really thorough roundup of protective cases.
    Does anyone have any firsthand experience or recommendations for protective cases?

    Thanks for the Google Base link, but it doesn't seem to work any more.
    I did manage to find some cases from a company called Technology Directions in Melburne, Australia.
    I needed something that would sit well on a shelf, but also offer good durability and anti-static protection. I also have some 2.5" drives from notebooks that no longer work, and some 3.5" drives that won't fit into my current system at the same time.
    I saw some good reviews, so I ordered a 10-pack and they arrived in under a week, with very reasonable shipping. They came with labels and foam padding (which I only needed for some of the drives). I now have 10 cases holding 14 drives, in protected bliss, on the shelf. I can read the label and instantly see which drive I need, instead of peering into anti-static bags. Highly recommended.

  • ORA-32036 while using WITH

    I will include the query below my question as it is very long.
    I am using Microsoft SQL Server Reporting Services to connect to an Oracle Database (9i v 2). When I put in the query below I get the following error coming from the Oracle Server -
    "TITLE: Microsoft Report Designer
    An error occurred while executing the query.
    ORA-32036: unsupported case for inlining of query name in WITH clause"
    I found an explanation for this error - "     There is at least one query name which is inlined more than once because it's definition query is too simple and references another query name. This is currently unsupported yet." - and taking out the sub-queries one by one it seems to be COMBINE_TWO sub-query that causes the issue. Apparently it doesn't like the Select * from BLAHBLAH and finds it to be unecessary. I have made this query using nested selects - but the code gets redundant and I end up having to use the same query two or three times....the whole statement takes far too long to execute.
    Any coding suggestions or workaround suggestions would be appreciated - I have been looking at this problem so long that I have tunnel vision. There has to be a fix or a better way...
    Thanks!
    Brett
    Here is the query....
    WITH 
      /*This query finds all pending WO's and caculates all changing service
      levels for limited, basic, internet and phone.  Any values that do not
      change are kept at null, any services being disconnected are dropped to a negative
      and service being upgrades and/or downgraded but still kept are valued
      at their to_quantity value. */
      STEP_1 AS
        SELECT
          WO.ACCOUNT_NUMBER,
          WO.WORK_ORDER_NUMBER,
          WO.WO_TYPE,
          WOD.SERVICE_CODE,
          CASE WHEN WOD.SERVICE_CODE = '101' AND WOD.FROM_QUANTITY != WOD.TO_QUANTITY THEN WOD.TO_QUANTITY - WOD.FROM_QUANTITY ELSE NULL END LIM,
          CASE WHEN WOD.SERVICE_CODE = '111' AND WOD.FROM_QUANTITY != WOD.TO_QUANTITY THEN WOD.TO_QUANTITY - WOD.FROM_QUANTITY ELSE NULL END EXP,
          CASE WHEN WOD.SERVICE_CODE = '30001' AND WOD.FROM_QUANTITY != WOD.TO_QUANTITY THEN WOD.TO_QUANTITY - WOD.FROM_QUANTITY ELSE NULL END HSI,
          CASE WHEN WOD.SERVICE_CODE IN ('LINE FL', 'ULTS FL') AND WOD.FROM_QUANTITY != WOD.TO_QUANTITY THEN WOD.TO_QUANTITY - WOD.FROM_QUANTITY ELSE NULL END PHONE
        FROM
          KAN_WORK_ORDER_MASTER WO INNER JOIN KAN_WORK_ORDER_DETAIL WOD ON WO.WORK_ORDER_NUMBER = WOD.WORK_ORDER_NUMBER
        WHERE
          WO.WO_TYPE IN ('DI', 'DW', 'IN', 'SR', 'UP')
          AND WOD.SERVICE_CODE IN ('101', '111', '30001', 'LINE FL', 'ULTS FL')
          AND POOL = 'A'
          AND WO_STATUS = ' '),
    /* This adds all values from step 1 and condenses all work orders
    into one row, a value for each service. */
    STEP_2 AS
        SELECT
          ACCOUNT_NUMBER,
          WORK_ORDER_NUMBER,
          WO_TYPE,
          SUM(LIM) LIM,
          SUM(EXP) EXP,
          SUM(HSI) HSI,
          SUM(PHONE) PHONE
        FROM
          STEP_1
        GROUP BY
          ACCOUNT_NUMBER,
          WORK_ORDER_NUMBER,
          WO_TYPE
        ORDER BY
          ACCOUNT_NUMBER),
      /* This query takes the results from Step 2 and then looks at all service
      levels that were not included or changed in the work order detail file
      and makes sure that unchanged services are included in the final total.
      FOR EXAMPLE : Coming from step 2, if LIM is NULL we know that no changes
      were done to LIM in the work order - so, if the customer has Limited then
      the service quantity is added to the total.  Else - if LIM is not null, then
      we know the service level was effected by the work order - so do not
      include the quantity from the services file because it will be innacurate
      once the work order is complete*/
      STEP_3 AS
       SELECT
          WO.ACCOUNT_NUMBER,
          WO.WORK_ORDER_NUMBER,
          WO.WO_TYPE,
          CASE WHEN LIM IS NULL AND CS.SERVICE_CODE = '101' THEN (CS.SERVICE_QUANTITY + CS.SERVICE_QUANTITY_TO_FREE) ELSE NULL END LIM,
          CASE WHEN EXP IS NULL AND CS.SERVICE_CODE = '111' THEN (CS.SERVICE_QUANTITY + CS.SERVICE_QUANTITY_TO_FREE) ELSE NULL END EXP,
          CASE WHEN HSI IS NULL AND CS.SERVICE_CODE = '30001' THEN (CS.SERVICE_QUANTITY + CS.SERVICE_QUANTITY_TO_FREE) ELSE NULL END HSI,
          CASE WHEN PHONE IS NULL AND CS.SERVICE_CODE IN ('LINE FL', 'ULTS FL') THEN (CS.SERVICE_QUANTITY + CS.SERVICE_QUANTITY_TO_FREE) ELSE NULL END PHONE
        FROM
          STEP_2 WO INNER JOIN KAN_CUSTOMER_SERVICES CS ON WO.ACCOUNT_NUMBER = CS.ACCOUNT_NUMBER
        WHERE
          CS.SERVICE_CODE IN ('101', '111', '30001', 'LINE FL', 'ULTS FL')
          AND CS.SERVICE_STATUS = 'A'),
      /* This step calculated the current service level. */
      STEP_4 AS
        SELECT
              ACCOUNT_NUMBER,
              WORK_ORDER_NUMBER,
              WO_TYPE,
              SUM(LIM) LIM,
              SUM(EXP) EXP,
              SUM(HSI) HSI,
              SUM(PHONE) PHONE
            FROM
              STEP_3
            GROUP BY
              ACCOUNT_NUMBER,
              WORK_ORDER_NUMBER,
              WO_TYPE
      COMBINE_TWO AS
        SELECT
        FROM
          STEP_2
        UNION ALL
        SELECT
        FROM
          STEP_4
        SELECT
          WOM.SCHEDULE_DATE,
          COMBINE_TWO.ACCOUNT_NUMBER,
          COMBINE_TWO.WORK_ORDER_NUMBER,
          COMBINE_TWO.WO_TYPE,
          HM.ADDRESS_LINE_1,
          HM.ADDRESS_LINE_2,
          HM.ADDRESS_LINE_3,
          HM.ADDRESS_LINE_4,
          SUM(LIM) LIM,
          SUM(EXP) EXP,
          SUM(HSI) HSI,
          SUM(PHONE) PHONE
        FROM
            COMBINE_TWO
            INNER JOIN KAN_CUSTOMER_MASTER CM ON COMBINE_TWO.ACCOUNT_NUMBER = CM.ACCOUNT_NUMBER
            INNER JOIN KAN_HOUSE_MASTER HM ON CM.HOUSE_NUMBER = HM.HOUSE_NUMBER
            INNER JOIN KAN_WORK_ORDER_MASTER WOM ON COMBINE_TWO.WORK_ORDER_NUMBER = WOM.WORK_ORDER_NUMBER
        GROUP BY
          WOM.SCHEDULE_DATE,
          COMBINE_TWO.ACCOUNT_NUMBER,
          COMBINE_TWO.WORK_ORDER_NUMBER,
          COMBINE_TWO.WO_TYPE,
          HM.ADDRESS_LINE_1,
          HM.ADDRESS_LINE_2,
          HM.ADDRESS_LINE_3,
          HM.ADDRESS_LINE_4
        HAVING
            SUM(LIM) <= 0
            AND SUM(EXP) <= 0
          AND
            SUM(HSI) >= 1
            OR SUM(PHONE) >= 1
        ORDER BY
          ACCOUNT_NUMBER

    GREAT job posting and formatting the query. Also helpful was your really good documentation in the query.
    You seem to be approaching your problem in the right way. You are pushing the limits of sql is capable of doing.
    Here are some ideas that you can consider and probably discard; I don't have any good ones but maybe these can encourage you or someone else to think of something better. Sometimes you have to consider and discard bad ideas before getting to the good ones - its part of the process.
    The query is complex enough - how many steps, with unions and subqueries galore - maybe a deconstructed pipelined function would be easier.
    Views aren't usually an answer to problems like this, and more often than not cause other problems later when somebody tries to join to them.
    Deconstructing the query and putting the incremental step data into global temporary tables might work, with a query at the end to read the final result set.

  • ORA-32036

    I am getting following error in an SQL statement that has a complicated with clause:
    ORA-32036: unsupported case for inlining of query name in WITH clause
    The with clause here in the query is too complicated and involves lots of subqueries.
    Has anyone encountered such error before and knows the solution for this.
    The problem is something like this:
    ORA-32036
    I have a query that I wrote that uses temp tables in it: (simple example)
    with data as (select * from table1) select * from data, table1 where table1.id = data.id (simpler version than actual complex code)
    The query runs quickly when I run it directly against Oracle, but when I try to call it through my java code I get the oracle error "ORA-32036: unsupported case for inlining of query name in WITH clause". I have also tried running the query in a stored proc and calling that from the java code and I get the same error. Any suggestions?
    My db is 10.2.1
    Thanks
    Edited by: rohitgoswami on Sep 23, 2008 4:05 PM

    The PL/SQL code as called from where? From java or called naively from SQLPLUS? Based on your last post it sounds like it only fails when being initiated from JAVA.
    *The query runs quickly when I run it directly against Oracle*, but when I try to call it through my java code I get the oracle error "ORA-32036: unsupported case for inlining of query name in WITH clause". I have also tried running the query in a stored proc and calling that from the java code and I get the same error. Any suggestions?
    I find it hard to believe that it fails intermittently like that, more likely it's failing with consistency, but you're loading up the temp table in an inconsistent (change with executions) manner, or is that not the case? Have you checked?
    I'd still recommend checking MetaLink (have you even looked there?) for known bugs, and possibly patch your database up to a current patch set.
    Aside from that, rewrite your SQL query....

  • Need help locating a wallet case for an Xperia T2 Ultra Smartphone that has a slot on the side for the mini-usb

    I realize this board is for Xperia tablets, but I don't see a board for Xperia Smartphones.  I do hope someone here can help. I have a Sony Xperia T2 Ultra smartphone.  I love the phone, but I purchased a case for it not realizing that the case doesn't have a slot on the side for the mini-usb connector, which means that I have to charge the phone with the case open.
    I called Sony accessories, and they don't seem to make a case with a slot on the side.  They have a very nice case, but again, it doesn't have the correct opening for the charger and you have to charge the phone with the case open.
    I have also searched several websites for such a case with no luck.
    Does anyone here know where I can find a wallet-style case for the Sony Xperia T2 Ultra with a magnetic closure (or some way of securing the case closed) that will actually allow me to charge the phone while the case is closed?  Please let me know.

    This is the only "question" I could extract out of your confusing post:
    "I want to know if it even can be done in Flash or would we need to use something else like PHP or Javascript?"
    It can`t be done in Flash alone you need php.
    With the experience level you already admitted to, I strongly advise to stay away from such a project, you will save you and our customer a lot of headaches, no offense.

  • Table for Webtemplate and Query mapping

    Hi Experts,
    Is there any table which has the mapping for BW Web template and the Query on which this Web Template is built.
    Any help would be highly appreciated.
    Regards,
    Rk.

    >
    Matthias Nutt wrote:
    > Hi,
    >
    > the WebTemplate is stored as XML document. This is the XML code which is shown in the Web Application Designer. You need to read throught the XML using the Web Application Designer or using report RS_TEMPLATE_MAINTAIN_70.
    >
    > Regards Matthias Nutt
    > SAP Consulting Switzerland
    Hi,
    Thanks for the reply.
    What is the output for this report?
    I just need the query name which is used for creating the Web Template.
    Any table, FM or ABAP program for getting the query name for a Web Template will be sufficient for my requirement.
    Regards,
    Rk.

  • Custom Case for Macbook Pro 15 Retina

         I have been looking for a place where I can create a custom hard physical case for a 15 inch macbook pro with retina display.  In my searchings I have only found custom skins and decals.  Does anybody know where I can create a custom plastic (or something like that) case for a macbook pro.  I DO NOT WANT TO GET A SKIN OR DECAL, BUT AN ACTUAL CASE.

    Hi  Macsaregreat I found a company that does them the link is http://www.mrnutcase.com/en-GB/personalised-macbook-cover/ it is an actual hard plastic case for the top and bottom, I love mine came really quick as well.
    Hope that helps

  • Otter Box Armor Case for iPhone 5

    I know this is Apple Forums, but if anybody needs a  pouch with belt clip for Otterbox Armor Case for iPhone 5, consider a pouch with belt clip designed for Galaxy S3. I got this "third party" like Amazon, it is REIKO brand pouch with belt clip. My iPhone 5 with Armor case fits snug in this pouch, if somebody found something better, good for you!

    Since it is not listed as an available case for the 5s, I would think not.:
    http://www.otterbox.com/apple-iphone-5s-cases/apple-iphone-5s-cases,default,sc.h tml

  • Avoiding WITH clause when querying Multiple Facts

    OBIEE 10.1.3.4
    We have a report which requires that we query multiple facts, which share the same Item dimension.
    When we run the report, the BI Server generates a query using the WITH clause -
    WITH SAWITH0 ( SELECT.............)
    SAWITH1( SELECT .............)
    SELECT .........
    FROM SAWITH0 FULL OUTER JOIN SAWITH1
    The above query errors out with ORA-918 Column Ambiguously Defined. I cannot find any issue in the query that has been generated.
    The query does fail from SQL Plus with the same ORA error. But each of the select statements executed properly and the complete statement executes when I replace the FULL OUTER JOIN with INNER JOIN.
    I can only assume that this is a bug in Oracle Database.
    Now at times I have seen OBIEE generate separate queries when querying multiple facts and then combine the data together in memory.
    Is there a way that I can force OBIEE to avoid using WITH clause and run separate SELECT statements ? How does the BI Server choose between using a WITH clause or running separate queries ?
    Any help would be appreciated.

    I do not have a multi-dimensional data source.
    My connection pool seems fine to me, I am not sure I need to do anything with the connection pool.
    Hi Turribeach,
    I understand that BI Server uses WITH clause for multiple facts. But I have also seen it issue separate queries against the database.
    So what I am looking to understand under what situation does it issue separate queries i.e. No WITH clause ?
    Thanks

  • WITH CLAUSE: ORA-32034

    Hello,
    I have a query that requires WITH clauses since it reiterates a similar select, so I'm down with 2 WITH clause which I cannot unionize. How can I do this?
    Thanks Pierre
    with DURCDR as (select CALLINGPARTYNUMBER,CALLINGPARTYIMSI,CALLINGPARTYIMEI,CALLEDPARTYNUMBER,CALLEDPAR
    TYIMSI,CALLEDPARTYIMEI,
    CHARGINGSTARTTIME,REDIRECTINGPARTYIMEI,REDIRECTINGPARTYIMSI,REDIRECTINGPARTYNUMB
    ER from bgw_durcdr where CHARGINGSTARTTIME BETWEEN '01-05-2007:00:00:00' and '01-05-2007:23:59:59'
    and (CALLEDPARTYIMEI IN '2980' or CALLINGPARTYIMEI IN '2980' OR REDIRECTINGPARTYIMEI IN '2980'))
    SELECT
    CALLEDPARTYNUMBER,
    CALLEDPARTYIMSI,
    CALLEDPARTYIMEI,
    CHARGINGSTARTTIME
    FROM DURCDR
    UNION
    SELECT
    CALLINGPARTYNUMBER,
    CALLINGPARTYIMSI,
    CALLINGPARTYIMEI,
    CHARGINGSTARTTIME
    FROM DURCDR
    UNION
    SELECT
    REDIRECTINGPARTYIMEI,
    REDIRECTINGPARTYIMSI,
    REDIRECTINGPARTYNUMBER,
    CHARGINGSTARTTIME
    FROM
    DURCDR ==> GET ERROR ORA-32034
    UNION
    WITH EVTCDR AS(select DESTINATION,DESTINATIONIMSI,DESTINATIONIMEI,CHARGINGSTARTTIME,ORIGINIMEI,ORIGINI
    MSI,ORIGIN,REDIRECTINGPA
    RTYIMEI,REDIRECTINGPARTYIMSI,REDIRECTINGPARTYNUMBER FROM BGW_EVTCDR WHERE CHARGINGSTARTTIME BETWEEN '01-05-2007:00:00:00' and '01-05-2007:23:59:59'
    AND( DESTINATIONIMEI IN '2980' OR ORIGINIMEI IN '2980' OR REDIRECTINGPARTYIMEI IN '2980'))
    SELECT
    DESTINATION,
    DESTINATIONIMSI,
    DESTINATIONIMEI,
    CHARGINGSTARTTIME
    FROM EVTCDR
    UNION
    SELECT
    ORIGINIMEI,
    ORIGINIMSI,
    ORIGIN,
    CHARGINGSTARTTIME
    FROM EVTCDR
    UNION
    SELECT
    REDIRECTINGPARTYIMEI,
    REDIRECTINGPARTYIMSI,
    REDIRECTINGPARTYNUMBER,
    CHARGINGSTARTTIME
    FROM EVTCDR;

    (although the example you gave still fails in v10) Really ?
    SQL> select banner from v$version where rownum = 1;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    SQL> with d as (select deptno from emp), 
      2  s as (select deptno from dept) 
      3  select * from d 
      4  union 
      5  select * from s;
        DEPTNO
            10
            20
            30
            40Your example works with subquery which is the separate select statement.
    SQL> with t as (select 1 a from dual)
      2  select * from t where a in (
      3  with x as (select 2 b from dual)
      4  select b from x
      5  )
      6  /
    no rows selected
    SQL> with t as (select 1 a from dual),
      2  x as (select 2 b from dual)
      3  select * from t where a in (
      4  select b from x
      5  )
      6  /
    no rows selectedhttp://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#i2065646
    Restrictions on Subquery Factoring This clause is subject to the following restrictions:
    You can specify only one subquery_factoring_clause in a single SQL statement. You cannot specify a query_name in its own subquery. However, any query_name defined in the subquery_factoring_clause can be used in any subsequent named query block in the subquery_factoring_clause.
    In a compound query with set operators, you cannot use the query_name for any of the component queries, but you can use the query_name in the FROM clause of any of the component queries.
    Rgds.

  • How to get Query Names in webi Report ??

    Hello All,
    I'm trying to pull data from different data sources like accdb,Oracle,DB2,MDB,xls files . I pulled the data successfully by merging all queries.But I was stuck with getting the query names in report ...can some one guide me in this ?? I used data provider () but getting 1 query name along with my universe name.
    thanks in advance,
    Lavanya.

    Hi Lavanya,
    Are you interested to know the data sources of the queries or just the query names?
    To know the Query Name, you can use DataProvider( ) function; however, in case you wish to know the data source, you can use Connection( ) function.
    Regards,
    Yuvraj

Maybe you are looking for