Execution of SQL query error

Hello

You can see why I get this error message for my SQL query?
WITH SKU_DATA AS (
SELECT /*+ MATERIALIZE */ DISTINCT FROM_LOC_ID,
           SKU_ID,
           DESCRIPTION,
           UPDATE_QTY,
        ORDER_ID,
        CONSIGNMENT,
           WEIGHT,
        PALLET_ID,
        CASE  
    WHEN Upd_Qty_Ratio < 1 
    THEN TO_CHAR(UPDATE_QTY) || 'U'
    WHEN TRUNC(Upd_Qty_Ratio) = Upd_Qty_Ratio
    THEN TO_CHAR(Upd_Qty_Ratio) || 'C'
    ELSE TO_CHAR(TRUNC(UPDATE_QTY)) || 'C' || ' ' || TO_CHAR(ROUND(MOD(Upd_Qty_Ratio, 1) *  USER_DEF_NUM_3, 6)) || 'U'
    END CU_Sum
    FROM (
  SELECT DISTINCT
         FROM_LOC_ID,
      S.SKU_ID,
         S.DESCRIPTION,
         ITL.UPDATE_QTY,
         S.USER_DEF_NUM_3,
      OH.ORDER_ID,
      ITL.CONSIGNMENT,
      ITL.PALLET_ID,
         NVL(ITL.UPDATE_QTY,0)*NVL(S.EACH_WEIGHT,0) Weight,
         ITL.UPDATE_QTY/(CASE S.USER_DEF_NUM_3 WHEN 0 THEN 1 ELSE S.USER_DEF_NUM_3 END) Upd_Qty_Ratio
    FROM INVENTORY_TRANSACTION ITL, SKU S, LOCATION L, ORDER_HEADER OH
    WHERE ITL.SKU_ID = S.SKU_ID
    AND ITL.CODE = 'Pick'
    AND ITL.CONSIGNMENT = $P{Consignment}
    AND OH.ORDER_DATE = TO_CHAR($P{Date}, 'DD-Mon-YYYY')
    AND OH.ORDER_ID = ITL.REFERENCE_ID
    AND ITL.TO_LOC_ID = 'CONTAINER'))
SELECT DISTINCT ORDER_ID, CONSIGNMENT, WEIGHT, PALLET_ID, CU_Sum,
(SELECT NVL(TO_CHAR(SUM(CASE WHEN NULLIF(SUBSTR(Cu_Sum, -1), 'U') IS NULL THEN NULL ELSE REPLACE(Cu_Sum,'C',NULL) END)),'0') ||'C' || ' ' || NVL(TO_CHAR(SUM(CASE WHEN NULLIF(SUBSTR(Cu_Sum, -1), 'C') IS NULL THEN NULL ELSE REPLACE(Cu_Sum,'U',NULL) END)),'0') ||'U' FROM SKU_DATA) AS Total_Cu_Sum
FROM SKU_DATA
Thanks in advance.

SM.

Hello Sam, what is the error, and what has changed since he was executed successfully?

Tags: Database

Similar Questions

  • Feature of the parallel execution of SQL query

    Hello guys,.

    I installed a 11 GR 2 Oracle RAC (11.2.0.3) database, but I see the use of the feature of running parallel SQL queries, but I never used that.

    I would like to know if this feature is enabled by default on CCR environments and if it does not require me to pay for Enterprise Edition.

    NAME DETECTED_USAGES FIRST_USA LAST_USAG CURRE

    ---------------------------------------------------------------- --------------- ----- --------- ---------

    Checking Options 1 TRUE 9 October 15 October 9, 15

    BMG Auto setting 1 TRUE 9 October 15 October 9, 15

    Memory of the execution of SQL auto 1 TRUE 9 October 15 October 9, 15

    Automatic management of the space Segment (System) 1 TRUE 9 October 15 October 9, 15

    Automatic Storage Management 1 TRUE 9 October 15 October 9, 15

    Management of the Undo Automatic 1 TRUE 9 October 15 October 9, 15

    Character set 1 TRUE 9 October 15 October 9, 15

    Deferred Segment creation 1 TRUE 9 October 15 October 9, 15

    Locally managed tablespaces (System) 1 TRUE 9 October 15 October 9, 15

    Locally managed tablespaces (user) 1 TRUE 9 October 15 October 9, 15

    Logfile multiplexing 1 TRUE 9 October 15 October 9, 15

    Oracle Java Virtual Machine (System) 1 TRUE 9 October 15 October 9, 15

    Oracle utility of metadata API 1 TRUE 9 October 15 October 9, 15

    1 SQL query in parallel TRUE 9 October 15 October 9, 15

    Partitioning (System) 1 TRUE 9 October 15 October 9, 15

    Real Application Clusters (RAC) 1 TRUE 9 October 15 October 9, 15

    Recovery zone 1 TRUE 9 October 15 October 9, 15

    SECUREFICHIERS (System) 1 TRUE 9 October 15 October 9, 15

    SECUREFICHIERS (user) 1 TRUE 9 October 15 October 9, 15

    The parameter server file 1 TRUE 9 October 15 October 9, 15

    Thanks in advance,

    Franky

    You are not, but Oracle is, since you are using RAC.  Oracle relies on execution in parallel against the gv$ views so even if you can't use it in SE way common Oracle can when it comes to query against one of the points of view gv$.  That's why DBA_FEATURE_USAGE_STATISTICS reports that you see.

    David Fitzjarrell

  • SQL query error

    Any new request related to query below to display under the column data?

    IDSITE, IDVISIT, COUPON_ID, TRIM (INITCAP (PAGE_PATH) SELECT), INITCAP (keywords), LOCATION_IP, REFERER_NAME, REFERER_URL, VISIT_ACTION_TIME OF WEB_STATS with TRIM (INITCAP (PAGE_PATH)) = "Boston Pizza" and to_date (visit_action_time, 'DD-MON-RRRR') between to_date (5 July 2011 ',' DD-MON-RRRR') and to_date (5 July 2011 ',' DD-MON-RRRR')
    *
    ERROR on line 1:
    ORA-00979: not a GROUP BY expression

    863765 wrote:
    Any new request related to query below to display under the column data?

    IDSITE, IDVISIT, COUPON_ID, TRIM (INITCAP (PAGE_PATH) SELECT), INITCAP (keywords), LOCATION_IP, REFERER_NAME, REFERER_URL, VISIT_ACTION_TIME OF WEB_STATS with TRIM (INITCAP (PAGE_PATH)) = "Boston Pizza" and to_date (visit_action_time, 'DD-MON-RRRR') between to_date (5 July 2011 ',' DD-MON-RRRR') and to_date (5 July 2011 ',' DD-MON-RRRR')
    *
    ERROR on line 1:
    ORA-00979: not a GROUP BY expression

    SELECT idsite,
           idvisit,
           coupon_id,
           Trim(Initcap(page_path)),
           Initcap(keywords),
           location_ip,
           referer_name,
           referer_url,
           visit_action_time
    FROM   web_stats
    WHERE Trim(Initcap(page_path)) = 'Boston Pizza'
           AND To_date(visit_action_time, 'DD-MON-RRRR') BETWEEN
               To_date('05-jul-2011', 'DD-MON-RRRR') AND
               To_date('05-jul-2011', 'DD-MON-RRRR')  
    

    I doubt that all lines will be returned

    Published by: sb92075 on July 9, 2011 11:52

  • Execution of SQL query for slow down

    Hey all!

    I use 10g express with apex 3.1 edition, when I run this query:

    Select asig.idasig IDASIG, asig.idAsig 'C & oacute; Digo Asignatura", ID asig.idasig, substr (asig.codigoasig |) » '|| ASiG.nombre, 0, 40) "Asignatura", p.nombre | " '|| 'Responsible' p.apellidos, t.usuario 'T & eacute; Técnico", substr (ea.estado, 0, 22)"Estado not', ec.estado "Certificado de Estado", cert.idestado
    certificado cert, asignatura asig, histasig ha, profesor Técnico t, p, estado, estado ea
    where cert.idasig = asig.idasig and
    p.idprof = asig.idprof and
    t.idtecnico = asig.idtecnico and
    * cert.idasig (cert.fecha) in (select idasig, max (date) of the Group idasig certificado) and *.
    EC.idestado = cert.idestado and
    HA.idasig = asig.idasig and
    * ha.idasig (ha.fecha) in (select idasig, max (date) of the histasig of idasig group) and *.
    EA.idestado = ha.idestado

    It is too slow, making the query gets results in approximately 149 s.

    Can someone give me an idea...

    PD: the case is that we have another query that do almost the same thing but with this one, I get the results in less than 1 s.

    Just posting your query without any other information is meaningless for us.

    Start by reading this thread...

    [When your query takes too long... | http://forums.oracle.com/forums/thread.jspa?messageID=1812597#1812597]

  • Classic report shows wrong "could not parse the SQL query: ORA-00942" error after migrating app to the new environment

    After migrating my APEX 4.1 application to a new environment, one classic report displays a "cannot parse the SQL query: ORA-00942: table or view does not exist" error when the page is displayed. Change the region to report SQL source to somehow (e.g., remove spaces, changing the order of the variables in the WHERE clause) immediately solves the problem, but by returning to the source of the region causes the report error again (the source region valid code without error, however).

    Throw the error message:

    Select v.id,

    v.Col1

    of view_vw v

    where (: P1_FILTER is null or)

    v.col2 = :P1_FILTER)

    Do not throw error:

    Select v.id,

    v.Col1

    of view_vw v

    where (:P1_FILTER is null or)

    v.col2 = :P1_FILTER)

    Changing the order of column in the report has the same effect; i.e. He arranges, but return back to the original column order causes the error to display.

    It's as if a cached result for the correct select statement used by the report is displayed. However, the application does not use the caching of page/region. Any ideas of what could be the cause?

    He solved. Ultimately, all that was necessary was to clear the DB cache using:

    alter system flush shared_pool;

  • Table error ' can not analyze the SQL query!

    Hi all

    I created a view on my database called VIEW_MEMBER_PARTIC_PROJECTS

    If I run a query showing the results of the view:

    SELECT * FROM VIEW_MEMBER_PARTIC_PROJECTS

    I get the following data

    ProjectsParticipants
    131 S
    241
    319
    43
    53
    61
    72

    Now, I wanted to represent this diagram in the APEX so I created a graphic region and entered the Source query generator and the manufacturer produces the following code

    Select null, label projects, value1 Participant link

    of "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    With this code, I get an error:

    Cannot parse the SQL query!

    Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    Some queries can be run when you run your application, if your query is syntactically correct, you can save your query without validation (see options below the source of the query).

    The code looks OK, but I do not see to save options as the error code is mentioned.

    No one knows how to fix this?

    Thank you

    JaReg wrote:

    I finally found the problem.

    I looked at the code for the view and changed the start of:

    CREATE OR REPLACE FORCE EDITIONABLE VIEW "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS "("Participant","Projects")

    AS

    TO

    CREATE OR REPLACE VIEW "SCHEMANAME." "" VIEW_REPEAT_PARATIC ".

    AS

    And that seemed to fix it. I'm not entirely sure why though.

    The view was created using the quoted identifiers for column names. This makes them sensitive and means that they must always be referenced using double quotes. In the absence of quotation marks, Oracle is not case insensitive and automatically converts all uppercase identifiers. The application of graph:

    Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    has therefore been interpreted by Oracle:

    SELECT THE LINK NULL, LABEL, VALUE1 "SCHEMANAME PARTICIPANT PROJECTS." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    and PROJECTS and PARTICIPANT columns were not recognized because the columns defined for the view have been 'Participant' and 'projects '. The graphic request should have been:

    Select the link null, the label of "Projects", "Participant" value1 "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    As you have now discovered, quoted identifiers are a source of nothing but obscure bugs and should never be used for database objects. He also pointed out the reason why you should always use a standardized, form tiny, coding style as it is faster to type, easy to read and less prone to errors.

  • More than 1 SQL query with checkbox and error invalid number report

    Hi all

    I have two SQL query reports that each has an apex_item.checkbox and two processes for each report.  A report/process works very well.  It gives me an error of invalid number.

    In addition, another query SQL (editable report) gives me the following error when using the Multi line process, delete.

    ORA-06502: PL/SQL: digital or value error: character number conversion
    error ORA-06502: PL/SQL: digital or value error: character number conversion
    error
    Ok

    When I got a report from SQL query (with box and a process) and the query SQL (editable report) everything worked.  It stopped working when I added another SQL query report (with box and a process).

    A SQL query has the following in my query: apex_item.checkbox(3,email_id,'UNCHECKED') ""

    The other SQL query has the following: apex_item.checkbox(2,b.file_id,'UNCHECKED') ""

    Any help will be greatly appreciated,

    Sylvia

    Hi Reema,

    I've recreated the region and now it works!

    Thank you for this, looking at

    Sylvia

  • Error in the SQL query


    Hi all

    This my sql query.

    WITH t AS (select to_clob ("<?")) XML version = "1.0" encoding ="UTF - 8"? >

    " < = xmlns:prd prd:symbolReferenceData ' http://API.Platts.com/referenceData "> "

    XICE001, XICE002 < prd:symbol > < / prd:symbol >

    < prd:attributeClass > density API, Latest < / prd:attributeClass >

    ((< / prd:symbolReferenceData > ') double str).

    T_SYMBOL as (SELECT TO_CHAR (regexp_substr (SYMBOL, "[^ \,] +', 1, LEVEL")) SYMBOL)

    T,.

    XMLTABLE ("symbolReferenceData' PASSAGE xmltype (REPLACE(t.str,'prd:')))

    COLUMNS CLOB PATH 'symbol' symbol)

    CONNECT BY LEVEL < = LENGTH (SYMBOL) - LENGTH (REPLACE (SYMBOL, ",")) + 1

    AND PRIOR dbms_random. VALUE IS NOT NULL)

    t_attributeClass as (SELECT TO_CHAR (regexp_substr (attributeClass, "[^ \,] +', 1, LEVEL")) attributeClass)

    T,.

    XMLTABLE ("symbolReferenceData' PASSAGE xmltype (REPLACE(t.str,'prd:')))

    AttributeClass PATH 'attributeClass' CLOB COLUMNS)

    CONNECTION OF LEVEL < = LENGTH (attributeClass) - LENGTH (REPLACE (attributeClass, ',')) + 1

    AND PRIOR dbms_random. VALUE IS NOT NULL)

    SELECT the name of symbol 'symbol',

    'Name', NULL

    NOTHING "value."

    status "ok".

    OF T_SYMBOL

    UNION

    SELECT the symbol, NULL, NULL,

    Status of 'invalid symbol.

    OF T_SYMBOL;

    If I run the above query, it throws error, below

    ORA-06502: PL/SQL: digital error or value

    ORA-06512: at "SYS." XMLTYPE", line 272

    ORA-06512: at line 1

    06502 00000 - "PL/SQL: digital error or the value of %s.

    * Cause: A digital arithmetic error, String, conversion or coercion

    has occurred. For example, this error occurs if an attempt is made to

    assign the NULL value to a variable declared NOT NULL, or if a

    attempt to assign an integer greater than 99 to a variable

    NUMBER (2) declared.

    * Action: Change the data, how it is handled, or how it is so declared

    that values do not violate the constraints.

    All of the suggestions.

    Kind regards

    Fame

    I have it

    To do two with would adopt.

    WITH t AS (select to_clob ('))

    http://API.Platts.com/referenceData">

    XICE001, XICE002

    Density API, last

    double str),

    T_SYMBOL as (SELECT TO_CHAR (regexp_substr (SYMBOL, "[^ \,] +', 1, LEVEL")) SYMBOL)

    T,.

    XMLTABLE ("symbolReferenceData' PASSAGE xmltype (REPLACE(t.str,'prd:')))

    COLUMNS CLOB PATH 'symbol' symbol)

    CONNECT BY LEVEL<= length(symbol)="" -="" length(replace(symbol,="" ','))="" +="">

    AND PRIOR dbms_random. VALUE IS NOT NULL)

    T_SYMBOL_1 as (SELECT TO_CHAR (regexp_substr (SYMBOL, "[^ \,] +', 1, LEVEL")) SYMBOL)

    T,.

    XMLTABLE ("symbolReferenceData' PASSAGE xmltype (REPLACE(t.str,'prd:')))

    COLUMNS CLOB PATH 'symbol' symbol)

    CONNECT BY LEVEL<= length(symbol)="" -="" length(replace(symbol,="" ','))="" +="">

    AND PRIOR dbms_random. VALUE IS NOT NULL)

    t_attributeClass as (SELECT TO_CHAR (regexp_substr (attributeClass, "[^ \,] +', 1, LEVEL")) attributeClass)

    T,.

    XMLTABLE ("symbolReferenceData' PASSAGE xmltype (REPLACE(t.str,'prd:')))

    AttributeClass PATH 'attributeClass' CLOB COLUMNS)

    CONNECT BY LEVEL<= length(attributeclass)="" -="" length(replace(attributeclass,="" ','))="" +="">

    AND PRIOR dbms_random. VALUE IS NOT NULL)

    SELECT the name of symbol 'symbol',

    'Name', NULL

    NOTHING "value."

    status "ok".

    OF T_SYMBOL

    UNION

    SELECT the symbol, NULL, NULL,

    Status of 'invalid symbol.

    OF T_SYMBOL_1;

  • Reg: SQL query execution time

    Hi all

    How to identify the oracle sql query execution time.

    Thanks in advance.
    SQL> set timing on
    
  • Stop Error Message "Failed to parse the SQL query" appearing

    Hello

    I have a sql query that is built into a string and then compiled and executed at run time. This query lies in a region and is returned.

    The query uses a view that uses a database link. If the link of database falls down for some reason, the "Failed to Parse SQL Query" message and the details on the DB link not working. However, I want to be able to implement my own error message when this happens, but I can't find a way to capture the error. I have put an exception handler in the region but because the code is technically correct and only fails at runtime that is not catching it.

    Is anyway to catch this error and display my message?

    Thank you
    -Mark

    Hello

    Try to use condition to hide the region and instead of this report will show another area where is your custom error message?

    BR, Jari

  • Execution of the SQL query through 2 different databases to Oracle

    Hi all

    In Microsoft SQL server, we can run on 2 different databases depending on the type of SQL query:

    Select * from TEST1.dbo.GENERIC_TABLE1 union select * from TEST2.dbo.GENERIC_TABLE2;

    Test1 and TEST2 here is 2 different databases.

    Can we do the same in Oracle?

    Of course you can do it.
    Create a [database join | http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_5005.htm] from DB1 to DB2.

    Grant select on the tables of the DB2 schema with which you want to connect.

    And then, you can you can query as

    select * from DB1schema.emp
    union
    select * from emp@dblink_name;
    
  • performance issue with the Oracle SQL query

    Dears

    Good evening

    I am new to begin to use Oracle SQL, I have a sql query which takes longer to run in production.

    Each table in the query contains 1.2 million records and DBA suggested using the "Oracle - tips. I don't have good knowledge on this subject and the difficulties to implement this advice for imrpovise performance. In the product the jobs Informatica are failed and stuck with this problem of query performance.

    I ask this forum for an emergency for me to solve this problem by using "advice". kindly help me.

     

    SELECT
    CASE.ID,
    CASE. DTYPE,
    CASE. Version
    CASE. EXTERNAL_REF,
    CASE. CREATION_TS,
    RQ. TYPE
    Of
    PAS_CASE CASE,
    AS_REQUEST RQ,
    CN PAS_CONTEXT
    where rq.case_id = case.id
    AND rq.id = cn.request_id
    and rq. DTYPE = "MAINREQUEST."
    and rq. TYPE in
    (
    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )
    and CN. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
    AND CAST (CN. CREATION_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
    AND
    CAST (CN. CREATION_TS AS DATE) < TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)

    -2nd request

    SELECT
    RA.ID,
    RHEUMATOID ARTHRITIS. Version
    RHEUMATOID ARTHRITIS. REQUEST_ID,
    RA.NAME,
    RHEUMATOID ARTHRITIS. VALUE,
    RHEUMATOID ARTHRITIS. LOB_ID,
    RHEUMATOID ARTHRITIS. DTYPE,
    RHEUMATOID ARTHRITIS. CREATION_TS,
    TASK. MAIN_REQ_TYPE
    PAS_REQUESTATTRIBUTE RA
    Join
    (
    Select tsk.ID, tsk. TYPE, main_req_type main_req.
    of tsk PAS_REQUEST
    Join
    (
    Select cn.id as context_id, rq. TYPE main_req_type
    of PAS_REQUEST rq
    Cn PAS_CONTEXT
    where rq.id = cn.request_id
    and rq. DTYPE = "MAINREQUEST."
    and rq. TYPE in
    (
    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
    )
    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
    and cn.ID between the 20141999999999999 AND 20141800000000000
    and rq.ID between the 20141999999999999 AND 20141800000000000

    ) main_req
    On tsk.parent_context_id = main_req.context_id
    and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
    and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1
    ) task
    on the RA REQUEST_ID = task.ID
    and RA.ID between $$ LOW_ID1 AND $$ HIGH_ID1
    UNION

    SELECT
    RA.ID,
    RHEUMATOID ARTHRITIS. Version
    RHEUMATOID ARTHRITIS. REQUEST_ID,
    RA.NAME,
    RHEUMATOID ARTHRITIS. VALUE,
    RHEUMATOID ARTHRITIS. LOB_ID,
    RHEUMATOID ARTHRITIS. DTYPE,
    RHEUMATOID ARTHRITIS. CREATION_TS,
    MAIN_REQ. TYPE
    PAS_REQUESTATTRIBUTE RA
    Join
    (
    Select rq.id, rq.type
    of PAS_REQUEST rq
    Cn PAS_CONTEXT
    where rq.id = cn.request_id
    and rq. DTYPE = "MAINREQUEST."
    and rq. TYPE in
    (
    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
    )
    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
    and cn.ID between the 20141999999999999 AND 20141800000000000
    and rq.ID between the 20141999999999999 AND 20141800000000000
    ) main_req
    on the RA REQUEST_ID = main_req.ID

    -3rd request

    SELECT

    RB.ID,

    RB. DTYPE,

    RB. Version

    RB. TYPE,

    RB. CREATION_TS,

    RB. TASK_ID,

    RB. Color

    RB. GLOBAL_RESULT,

    TASK. MAIN_REQ_TYPE

    Of

    PAS_RESULTBLOCK RB

    Join

    (

    Select tsk.ID, tsk. TYPE, main_req_type main_req.

    of tsk PAS_REQUEST

    Join

    (

    Select cn.id as context_id, rq. TYPE main_req_type

    of PAS_REQUEST rq

    Cn PAS_CONTEXT

    where rq.id = cn.request_id

    and rq. DTYPE = "MAINREQUEST."

    and rq. TYPE in

    (

    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )

    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)

    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)

    and cn.ID between the 20141999999999999 AND 20141800000000000

    and rq.ID between the 20141999999999999 AND 20141800000000000

    ) main_req

    On tsk.parent_context_id = main_req.context_id

    and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    ) task

    We rb.task_id = task.ID

    and rb.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    and RB. TYPE is not null

    and RB. TYPE IN

    (

    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )

    UNION

    SELECT

    RB.ID,

    RB. DTYPE,

    RB. Version

    RB. TYPE,

    RB. CREATION_TS,

    RB. TASK_ID,

    RB. Color

    RB. GLOBAL_RESULT,

    TASK. MAIN_REQ_TYPE

    Of

    PAS_RESULTBLOCK RB

    Join

    (

    Select tsk.ID, tsk. TYPE, main_req_type main_req.

    of tsk PAS_REQUEST

    Join

    (

    Select cn.id as context_id, rq. TYPE main_req_type

    of PAS_REQUEST rq

    Cn PAS_CONTEXT

    where rq.id = cn.request_id

    and rq. DTYPE = "MAINREQUEST."

    and rq. TYPE in

    (

    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )

    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)

    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)

    and cn.ID between the 20141999999999999 AND 20141800000000000

    and rq.ID between the 20141999999999999 AND 20141800000000000

    ) main_req

    On tsk.parent_context_id = main_req.context_id

    and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    ) task

    We rb.task_id = task.ID

    and rb.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    and RB. TYPE is nullSELECT

    RB.ID,

    RB. DTYPE,

    RB. Version

    RB. TYPE,

    RB. CREATION_TS,

    RB. TASK_ID,

    RB. Color

    RB. GLOBAL_RESULT,

    TASK. MAIN_REQ_TYPE

    Of

    PAS_RESULTBLOCK RB

    Join

    (

    Select tsk.ID, tsk. TYPE, main_req_type main_req.

    of tsk PAS_REQUEST

    Join

    (

    Select cn.id as context_id, rq. TYPE main_req_type

    of PAS_REQUEST rq

    Cn PAS_CONTEXT

    where rq.id = cn.request_id

    and rq. DTYPE = "MAINREQUEST."

    and rq. TYPE in

    (

    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )

    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)

    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)

    and cn.ID between the 20141999999999999 AND 20141800000000000

    and rq.ID between the 20141999999999999 AND 20141800000000000

    ) main_req

    On tsk.parent_context_id = main_req.context_id

    and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    ) task

    We rb.task_id = task.ID

    and rb.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    and RB. TYPE is not null

    and RB. TYPE IN

    (

    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )

    UNION

    SELECT

    RB.ID,

    RB. DTYPE,

    RB. Version

    RB. TYPE,

    RB. CREATION_TS,

    RB. TASK_ID,

    RB. Color

    RB. GLOBAL_RESULT,

    TASK. MAIN_REQ_TYPE

    Of

    PAS_RESULTBLOCK RB

    Join

    (

    Select tsk.ID, tsk. TYPE, main_req_type main_req.

    of tsk PAS_REQUEST

    Join

    (

    Select cn.id as context_id, rq. TYPE main_req_type

    of PAS_REQUEST rq

    Cn PAS_CONTEXT

    where rq.id = cn.request_id

    and rq. DTYPE = "MAINREQUEST."

    and rq. TYPE in

    (

    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )

    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)

    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)

    and cn.ID between the 20141999999999999 AND 20141800000000000

    and rq.ID between the 20141999999999999 AND 20141800000000000

    ) main_req

    On tsk.parent_context_id = main_req.context_id

    and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    ) task

    We rb.task_id = task.ID

    and rb.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    and RB. TYPE is null

    -4th query

    SELECT
    RI.ID,
    UII DTYPE,
    UII Version
    UII RESULTBLOCK_ID,
    RI.NAME,
    UII VALUE,
    UII UNIT,
    UII Color
    UII LOB_ID,
    UII CREATION_TS,
    UII SEQUENCE,
    UII DETAILLEVEL,
    RES_BLK. MAIN_REQ_TYPE
    Of
    RI PAS_RESULTITEM
    Join
    (
    Select
    rb.ID, rb. TYPE rb_type, task. TYPE as the task_type, task. pas_resultblock rb main_req_type
    Join
    (
    Select tsk.ID, tsk. TYPE, main_req_type main_req.
    of tsk PAS_REQUEST
    Join
    (
    Select cn.id as context_id, rq. TYPE main_req_type
    of PAS_REQUEST rq
    Cn PAS_CONTEXT
    where rq.id = cn.request_id
    and rq. DTYPE = "MAINREQUEST."
    and rq. TYPE in
    (
    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
    )
    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
    and cn.ID between the 20141999999999999 AND 20141800000000000
    and rq.ID between the 20141999999999999 AND 20141800000000000
    ) main_req
    On tsk.parent_context_id = main_req.context_id
    and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
    and tsk.ID between the 20141999999999999 AND 20141800000000000
    ) task
    We rb.task_id = task.ID
    and rb.ID between the 20141999999999999 AND 20141800000000000
    and RB. TYPE IN
    (
    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
    )
    ) res_blk
    On ri.resultblock_id = res_blk.ID
    where IN RI.NAME
    (
    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
    )
    and RI.ID between the 20141999999999999 AND 20141800000000000
    and RI.NAME is not null
    UNION

    Select
    RI.ID,
    UII DTYPE,
    UII Version
    UII RESULTBLOCK_ID,
    RI.NAME,
    UII VALUE,
    UII UNIT,
    UII Color
    UII LOB_ID,
    UII CREATION_TS,
    UII SEQUENCE,
    UII DETAILLEVEL,
    RES_BLK. MAIN_REQ_TYPE
    of pas_resultitem ri
    Join
    (
    Select
    rb.ID, rb. TYPE rb_type, task. TYPE as the task_type, task. pas_resultblock rb main_req_type
    Join
    (
    Select tsk.ID, tsk. TYPE, main_req_type main_req.
    of tsk PAS_REQUEST
    Join
    (
    Select cn.id as context_id, rq. TYPE main_req_type
    of PAS_REQUEST rq
    Cn PAS_CONTEXT
    where rq.id = cn.request_id
    and rq. DTYPE = "MAINREQUEST."
    and rq. TYPE in
    (
    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
    )
    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
    and cn.ID between the 20141999999999999 AND 20141800000000000
    and rq.ID between the 20141999999999999 AND 20141800000000000
    ) main_req
    On tsk.parent_context_id = main_req.context_id
    and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
    and tsk.ID between the 20141999999999999 AND 20141800000000000
    ) task
    We rb.task_id = task.ID
    and rb.ID between the 20141999999999999 AND 20141800000000000
    ) res_blk
    On ri.resultblock_id = res_blk.ID
    where RI.ID between 20141800000000000 20141999999999999 AND
    and RI.NAME is null

    -REQUEST OF 5HT

    SELECT

    TSK.ID,

    TSK. Version

    TSK. DTYPE,

    TSK. CASE_ID,

    TSK. TYPE,

    TSK. CORRELATION_ID,

    TSK. INITIATOR,

    TSK. EXECUTOR,

    TSK. CATEGORY,

    TSK. PARENT_CONTEXT_ID,

    TSK. CREATION_TS,

    MAIN_REQ. MAIN_REQ_TYPE

    Of

    TSK PAS_REQUEST

    Join

    (

    Select cn.id as context_id, rq. TYPE main_req_type

    of PAS_REQUEST rq

    Cn PAS_CONTEXT

    where rq.id = cn.request_id

    and rq. DTYPE = "MAINREQUEST."

    and rq. TYPE in

    (

    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )

    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)

    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)

    and cn.ID between the 20141999999999999 AND 20141800000000000

    and rq.ID between the 20141999999999999 AND 20141800000000000

    ) main_req

    On tsk.parent_context_id = main_req.context_id

    and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1

    UNION

    Select

    MREQ.ID,

    MREQ. Version

    MREQ. DTYPE,

    MREQ. CASE_ID,

    MREQ. TYPE,

    MREQ. CORRELATION_ID,

    MREQ. INITIATOR,

    MREQ. EXECUTOR,

    MREQ. CATEGORY,

    MREQ. PARENT_CONTEXT_ID,

    MREQ. CREATION_TS,

    MREQ. TYPE

    of PAS_REQUEST mreq

    Cn PAS_CONTEXT

    where mreq.id = cn.request_id

    and mreq. DTYPE = "MAINREQUEST."

    and mreq. TYPE in

    (

    'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.

    )

    and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)

    and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)

    and cn.ID between the 20141999999999999 AND 20141800000000000

    and mreq.ID between the 20141999999999999 AND 20141800000000000

    Tips will be may not be necessary (proportional to the cardinalities need)


    Select pc.id, pc.dtype, pc.version, pc.external_ref, pc.creation_ts, rq.type

    from pas_case

    as_request rq,

    CN pas_context

    where rq.case_id = pc.id

    and rq.id = cn.request_id

    and rq.dtype = 'MAINREQUEST. '

    and rq.type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.tbf.repair.vap',

    'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.

    'bgc.dar.e2etest.preparation ','bgc.chc.polling '.

    )

    and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and cn.creation_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')

    and cn.creation_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">

    -2nd request

    with

    main_request as

    (select / * + materialize * /)

    CN.ID as context_id, rq.type as main_req_type

    of pas_request rq

    Join

    CN pas_context

    On rq.id = cn.request_id

    and rq.dtype = 'MAINREQUEST. '

    and rq.type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.chc.polling',

    'bgc.tbf.repair.vap ',' bgc.dar.e2etest', ' bgc.dar.e2etest.intermediate.execution ',.

    'bgc.cbm ','bgc.dar.e2etest.preparation '.

    )

    and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and cn.end_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')

    and cn.end_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">

    and cn.id between 20141800000000000 and 20141999999999999

    and rq.id between 20141800000000000 and 20141999999999999

    )

    Select ra.id, ra.version, ra.request_id, ra.name, ra.value, ra.lob_id, ra.dtype, ra.creation_ts, task.main_req_type

    of pas_requestattribute ra

    Join

    (select tsk.id, tsk.type, main_req.main_req_type

    from pas_request tsk

    Join

    main_request main_req

    On tsk.parent_context_id = main_req.context_id

    and tsk.dtype in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.id between $$ low_id1 and $$ high_id1

    ) task

    We ra.request_id = task.id

    and ra.id between $$ low_id1 and $$ high_id1

    Union

    Select ra.id, ra.version, ra.request_id, ra.name, ra.value, ra.lob_id, ra.dtype, ra.creation_ts, main_req.type

    of pas_requestattribute ra

    Join

    main_request main_req

    On ra.request_id = main_req.context_id

    -3rd request

    Select rb.id, rb.dtype, rb.version, rb.type, rb.creation_ts, rb.task_id, rb.color, rb.global_result, task.main_req_type

    of pas_resultblock rb

    Join

    (select tsk.id, tsk.type, main_req.main_req_type

    from pas_request tsk

    Join

    (select cn.id as context_id, rq.type as main_req_type

    of pas_request rq

    Join

    CN pas_context

    On rq.id = cn.request_id

    and rq.dtype = 'MAINREQUEST. '

    and rq.type in ('bgc.dar.vap.resolution.advice ','bgc.dar.e2etest.execution ',

    'bgc.tbf.repair.vap ','bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ','bgc.cbm ',.

    'bgc.dar.e2etest.preparation ','bgc.chc.polling '.

    )

    and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and cn.end_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')

    and cn.end_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">

    and cn.id between 20141800000000000 and 20141999999999999

    and rq.id between 20141800000000000 and 20141999999999999

    ) main_req

    On tsk.parent_context_id = main_req.context_id

    and tsk.dtype in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.id between $$ low_id1 and $$ high_id1

    ) task

    We rb.task_id = task.id

    and rb.id between $$ low_id1 and $$ high_id1

    where the type is null

    or (type is not null

    type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ', ' bgc.tbf.repair.vap',

    'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.

    'bgc.dar.e2etest.preparation ','bgc.chc.polling '.

    )

    )

    -4th query

    Select ri.id, ri.dtype, ri.version, ri.resultblock_id, ri.name, ri.value, ri.unit, ri.color, ri.lob_id.

    RI.creation_ts, RI. Sequence, RI. DetailLevel, res_blk.main_req_type

    of pas_resultitem ri

    Join

    (select rb.id, rb.type as rb_type, task.type as task_type, task.main_req_type)

    of pas_resultblock rb

    Join

    (select main_req_type, tsk.id, tsk.type, main_req.)

    from pas_request tsk

    Join

    (select cn.id as context_id, rq.type as main_req_type

    of pas_request rq

    Join

    CN pas_context

    On rq.id = cn.request_id

    and rq.dtype = 'MAINREQUEST. '

    and rq.type in ('bgc.dar.vap.resolution.advice ','bgc.dar.e2etest.execution ',

    'bgc.tbf.repair.vap ','bgc.dar.e2etest ',.

    'bgc.dar.e2etest.intermediate.execution ','bgc.cbm ',.

    'bgc.dar.e2etest.preparation ','bgc.chc.polling '.

    )

    and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and cn.end_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')

    and cn.end_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">

    and cn.id between 20141800000000000 and 20141999999999999

    and rq.id between 20141800000000000 and 20141999999999999

    ) main_req

    On tsk.parent_context_id = main_req.context_id

    and tsk.dtype in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.id between 20141800000000000 and 20141999999999999

    ) task

    We rb.task_id = task.id

    and rb.id between 20141800000000000 and 20141999999999999

    and rb.type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.tbf.repair.vap',

    'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.

    'bgc.dar.e2etest.preparation ','bgc.chc.polling '.

    )

    ) res_blk

    On ri.resultblock_id = res_blk.id

    and ri.id between 20141800000000000 and 20141999999999999

    where ri.name is null

    or (ri.name is not null

    and ri.name in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.tbf.repair.vap',

    'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.

    'bgc.dar.e2etest.preparation ','bgc.chc.polling '.

    )

    )

    -5th application

    with

    main_request as

    (select / * + materialize * / )

    mreq.ID, mreq.version, mreq.dtype, mreq.case_id, mreq.type, mreq.correlation_id, mreq. Initiator, mreq. Executor,

    mreq. Category, mreq.parent_context_id, mreq.creation_ts, mreq.type

    of pas_request mreq

    Join

    CN pas_context

    On mreq.id = cn.request_id

    and mreq.dtype = 'MAINREQUEST. '

    and mreq.type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.tbf.repair.vap',

    'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.

    'bgc.dar.e2etest.preparation ','bgc.chc.polling '.

    )

    and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')

    and cn.end_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')

    and cn.end_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">

    and cn.id between 20141800000000000 and 20141999999999999

    and mreq.id between 20141800000000000 and 20141999999999999

    )

    Select tsk.id, tsk.version, tsk.dtype, tsk.case_id, tsk.type, tsk.correlation_id, tsk.initiator, tsk.executor,

    TSK. Category, tsk.parent_context_id, tsk.creation_ts, main_req.main_req_type

    from pas_request tsk

    Join

    main_request main_req

    On tsk.parent_context_id = main_req.id

    and tsk.dtype in ('ANALYSIS_TASK', 'DECISION_TASK')

    and tsk.id between $$ low_id1 and $$ high_id1

    Union

    SELECT id, version, dtype, case_id, type, correlation_id, initiator, executor,

    category, type parent_context_id, creation_ts

    of main_request

    Concerning

    Etbin

  • SQL Query + long running.

    Dear gurus/masters/All,
    I beg you all to help me with the setting of the SQL query that takes more time. DB version: 10.2.0.4

    Query SQL WHERE condition:
    select column1, column2, .........
    FROM
    SIEBEL.S_ORG_EXT T1,
    SIEBEL.S_PROD_INT T2,
    SIEBEL.S_VOD T3,
    SIEBEL.S_ORG_EXT T4,
    SIEBEL.S_ORG_EXT T5,
    SIEBEL.S_ORG_EXT_X T6,
    SIEBEL.S_PROD_LN T7,
    SIEBEL.S_ASSET_OM T8,
    SIEBEL.S_VOD_VER T9,
    SIEBEL.S_CTLG_CAT T10,
    SIEBEL.S_CONTACT T11,
    SIEBEL.S_PARTY T12,
    SIEBEL.S_PARTY T13,
    SIEBEL.S_PROD_INT T14,
    SIEBEL.S_ASSET_BU T15,
    SIEBEL.S_CTLG_CAT T16,
    SIEBEL.S_ORG_EXT T17,
    SIEBEL.S_ORG_EXT T18,
    SIEBEL.S_ASSET T19,
    SIEBEL.S_ADDR_PER T20,
    SIEBEL.S_ORG_EXT T21,
    SIEBEL.S_ASSET_X T22,
    SIEBEL.S_ASSET T23
    WHERE
    T16.PAR_CAT_ID = T10.ROW_ID (+) AND
    T14.CG_PR_CTLG_CAT_ID = T16.ROW_ID (+) AND
    T3.ROW_ID = T9.VOD_ID AND
    T14.CFG_MODEL_ID = T3.OBJECT_NUM AND
    T23.OWNER_CON_ID = T11.ROW_ID (+) AND
    T23.OWNER_ACCNT_ID = T6.PAR_ROW_ID (+) AND
    T23.PER_ADDR_ID = T20.ROW_ID (+) AND
    T23.PROD_ID = T14.ROW_ID AND
    T23.OWNER_ACCNT_ID = T21.PAR_ROW_ID (+) AND
    T14.PR_PROD_LN_ID = T7.ROW_ID (+) AND
    T23.ROOT_ASSET_ID = T19.ROW_ID (+) AND
    T19.PROD_ID = T2.ROW_ID (+) AND
    T23.BILL_ACCNT_ID = T18.PAR_ROW_ID (+) AND
    T23.RTNG_DLR_ID = T1.PAR_ROW_ID (+) AND
    T23.PREF_SRV_DLR_ID = T17.PAR_ROW_ID (+) AND
    T23.DLR_ID = T4.PAR_ROW_ID (+) AND
    T23.ROW_ID = T22.PAR_ROW_ID (+) AND
    T23.ROW_ID = T8.PAR_ROW_ID (+) AND
    T23.PR_CON_ID = T12.ROW_ID (+) AND
    T23.BU_ID = T15.BU_ID (+) AND T23.ROW_ID = T15.ASSET_ID (+) AND
    T15.BU_ID = T13.ROW_ID (+) AND
    T15.BU_ID = T5.PAR_ROW_ID (+) AND
    ((T23.SERIAL_NUM IS NOT NULL AND T23.PAR_ASSET_ID IS NULL OR T23.X_PHONE_NUMBER IS NOT NULL AND T23.PAR_ASSET_ID IS NOT NULL) AND 
     (T9.VER_NUM = :1));
    Query execution plan:
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 967177145
    
    --------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                         | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                                  |                | 54117 |    92M|  4435K  (1)| 01:58:43 |
    |   1 |  NESTED LOOPS OUTER                               |                | 54117 |    92M|  4435K  (1)| 01:58:43 |
    |   2 |   NESTED LOOPS OUTER                              |                | 54117 |    87M|  4261K  (1)| 01:54:04 |
    |   3 |    NESTED LOOPS OUTER                             |                | 54117 |    86M|  4154K  (1)| 01:51:13 |
    |   4 |     NESTED LOOPS OUTER                            |                | 54117 |    85M|  4111K  (1)| 01:50:03 |
    |   5 |      NESTED LOOPS OUTER                           |                | 54117 |    84M|  3980K  (1)| 01:46:33 |
    |   6 |       NESTED LOOPS OUTER                          |                | 54117 |    83M|  3937K  (1)| 01:45:24 |
    |   7 |        NESTED LOOPS OUTER                         |                | 54117 |    81M|  3763K  (1)| 01:40:44 |
    |   8 |         NESTED LOOPS OUTER                        |                | 54117 |    81M|  3751K  (1)| 01:40:25 |
    |   9 |          NESTED LOOPS OUTER                       |                | 54117 |    80M|  3621K  (1)| 01:36:57 |
    |  10 |           NESTED LOOPS OUTER                      |                | 54117 |    73M|  3515K  (1)| 01:34:07 |
    |  11 |            NESTED LOOPS OUTER                     |                | 54117 |    71M|  3410K  (1)| 01:31:18 |
    |  12 |             NESTED LOOPS OUTER                    |                | 54117 |    69M|  3410K  (1)| 01:31:18 |
    |  13 |              NESTED LOOPS OUTER                   |                | 54117 |    67M|  3410K  (1)| 01:31:18 |
    |  14 |               NESTED LOOPS OUTER                  |                | 54117 |    66M|  3410K  (1)| 01:31:18 |
    |  15 |                NESTED LOOPS OUTER                 |                | 54117 |    64M|  3324K  (1)| 01:28:59 |
    |  16 |                 NESTED LOOPS OUTER                |                | 54117 |    62M|  3237K  (1)| 01:26:40 |
    |  17 |                  NESTED LOOPS                     |                | 54117 |    57M|  3106K  (1)| 01:23:10 |
    |  18 |                   NESTED LOOPS OUTER              |                |    71 | 43665 |   381   (2)| 00:00:01 |
    |  19 |                    NESTED LOOPS OUTER             |                |    71 | 42316 |   323   (2)| 00:00:01 |
    |  20 |                     NESTED LOOPS OUTER            |                |    71 | 41322 |   322   (2)| 00:00:01 |
    |  21 |                      NESTED LOOPS                 |                |    71 | 24708 |   265   (3)| 00:00:01 |
    |  22 |                       NESTED LOOPS                |                |    77 |  2772 |   141   (4)| 00:00:01 |
    |* 23 |                        TABLE ACCESS FULL          | S_VOD_VER      |    75 |  1350 |    72   (7)| 00:00:01 |
    |  24 |                        TABLE ACCESS BY INDEX ROWID| S_VOD          |     1 |    18 |     1   (0)| 00:00:01 |
    |* 25 |                         INDEX UNIQUE SCAN         | S_VOD_P1       |     1 |       |     1   (0)| 00:00:01 |
    |  26 |                       TABLE ACCESS BY INDEX ROWID | S_PROD_INT     |     1 |   312 |     2   (0)| 00:00:01 |
    |* 27 |                        INDEX RANGE SCAN           | S_PROD_INT_F9  |     1 |       |     1   (0)| 00:00:01 |
    |  28 |                      TABLE ACCESS BY INDEX ROWID  | S_PROD_LN      |     1 |   234 |     1   (0)| 00:00:01 |
    |* 29 |                       INDEX UNIQUE SCAN           | S_PROD_LN_P1   |     1 |       |     1   (0)| 00:00:01 |
    |  30 |                     TABLE ACCESS BY INDEX ROWID   | S_CTLG_CAT     |     1 |    14 |     1   (0)| 00:00:01 |
    |* 31 |                      INDEX UNIQUE SCAN            | S_CTLG_CAT_P1  |     1 |       |     1   (0)| 00:00:01 |
    |  32 |                    TABLE ACCESS BY INDEX ROWID    | S_CTLG_CAT     |     1 |    19 |     1   (0)| 00:00:01 |
    |* 33 |                     INDEX UNIQUE SCAN             | S_CTLG_CAT_P1  |     1 |       |     1   (0)| 00:00:01 |
    |* 34 |                   TABLE ACCESS BY INDEX ROWID     | S_ASSET        |   760 |   375K| 43753   (1)| 00:01:11 |
    |* 35 |                    INDEX RANGE SCAN               | S_ASSET_U2     | 55873 |       |   312   (3)| 00:00:01 |
    |  36 |                  TABLE ACCESS BY INDEX ROWID      | S_ASSET_OM     |     1 |    94 |     2   (0)| 00:00:01 |
    |* 37 |                   INDEX RANGE SCAN                | S_ASSET_OM_U1  |     1 |       |     2   (0)| 00:00:01 |
    |  38 |                 TABLE ACCESS BY INDEX ROWID       | S_CONTACT      |     1 |    39 |     2   (0)| 00:00:01 |
    |* 39 |                  INDEX UNIQUE SCAN                | S_CONTACT_P1   |     1 |       |     1   (0)| 00:00:01 |
    |  40 |                TABLE ACCESS BY INDEX ROWID        | S_ADDR_PER     |     1 |    29 |     2   (0)| 00:00:01 |
    |* 41 |                 INDEX UNIQUE SCAN                 | S_ADDR_PER_P1  |     1 |       |     1   (0)| 00:00:01 |
    |  42 |               TABLE ACCESS BY INDEX ROWID         | S_ORG_EXT      |     1 |    32 |     1   (0)| 00:00:01 |
    |* 43 |                INDEX UNIQUE SCAN                  | S_ORG_EXT_U3   |     1 |       |     1   (0)| 00:00:01 |
    |  44 |              TABLE ACCESS BY INDEX ROWID          | S_ORG_EXT      |     1 |    32 |     1   (0)| 00:00:01 |
    |* 45 |               INDEX UNIQUE SCAN                   | S_ORG_EXT_U3   |     1 |       |     1   (0)| 00:00:01 |
    |  46 |             TABLE ACCESS BY INDEX ROWID           | S_ORG_EXT      |     1 |    32 |     1   (0)| 00:00:01 |
    |* 47 |              INDEX UNIQUE SCAN                    | S_ORG_EXT_U3   |     1 |       |     1   (0)| 00:00:01 |
    |  48 |            TABLE ACCESS BY INDEX ROWID            | S_ORG_EXT      |     1 |    36 |     2   (0)| 00:00:01 |
    |* 49 |             INDEX UNIQUE SCAN                     | S_ORG_EXT_U3   |     1 |       |     1   (0)| 00:00:01 |
    |  50 |           TABLE ACCESS BY INDEX ROWID             | S_ORG_EXT      |     1 |   139 |     2   (0)| 00:00:01 |
    |* 51 |            INDEX UNIQUE SCAN                      | S_ORG_EXT_U3   |     1 |       |     1   (0)| 00:00:01 |
    |  52 |          TABLE ACCESS BY INDEX ROWID              | S_ORG_EXT_X    |     1 |    16 |     2   (0)| 00:00:01 |
    |* 53 |           INDEX RANGE SCAN                        | S_ORG_EXT_X_U1 |     1 |       |     2   (0)| 00:00:01 |
    |* 54 |         INDEX UNIQUE SCAN                         | S_PARTY_P1     |     1 |    12 |     1   (0)| 00:00:01 |
    |  55 |        TABLE ACCESS BY INDEX ROWID                | S_ASSET_BU     |     1 |    34 |     3   (0)| 00:00:01 |
    |* 56 |         INDEX RANGE SCAN                          | S_ASSET_BU_U1  |     1 |       |     2   (0)| 00:00:01 |
    |* 57 |       INDEX UNIQUE SCAN                           | S_PARTY_P1     |     1 |    12 |     1   (0)| 00:00:01 |
    |  58 |      TABLE ACCESS BY INDEX ROWID                  | S_ASSET        |     1 |    37 |     2   (0)| 00:00:01 |
    |* 59 |       INDEX UNIQUE SCAN                           | S_ASSET_P1     |     1 |       |     2   (0)| 00:00:01 |
    |  60 |     TABLE ACCESS BY INDEX ROWID                   | S_PROD_INT     |     1 |    16 |     1   (0)| 00:00:01 |
    |* 61 |      INDEX UNIQUE SCAN                            | S_PROD_INT_P1  |     1 |       |     1   (0)| 00:00:01 |
    |  62 |    TABLE ACCESS BY INDEX ROWID                    | S_ORG_EXT      |     1 |    14 |     2   (0)| 00:00:01 |
    |* 63 |     INDEX UNIQUE SCAN                             | S_ORG_EXT_U3   |     1 |       |     1   (0)| 00:00:01 |
    |  64 |   TABLE ACCESS BY INDEX ROWID                     | S_ASSET_X      |     1 |    93 |     3   (0)| 00:00:01 |
    |* 65 |    INDEX RANGE SCAN                               | S_ASSET_X_U1   |     1 |       |     2   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
      23 - filter("T9"."VER_NUM"=TO_NUMBER(:1))
      25 - access("T3"."ROW_ID"="T9"."VOD_ID")
      27 - access("T14"."CFG_MODEL_ID"="T3"."OBJECT_NUM")
      29 - access("T14"."PR_PROD_LN_ID"="T7"."ROW_ID"(+))
      31 - access("T14"."CG_PR_CTLG_CAT_ID"="T16"."ROW_ID"(+))
      33 - access("T16"."PAR_CAT_ID"="T10"."ROW_ID"(+))
      34 - filter("T23"."PAR_ASSET_ID" IS NULL AND "T23"."SERIAL_NUM" IS NOT NULL OR "T23"."X_PHONE_NUMBER" IS
                  NOT NULL AND "T23"."PAR_ASSET_ID" IS NOT NULL)
      35 - access("T23"."PROD_ID"="T14"."ROW_ID")
      37 - access("T23"."ROW_ID"="T8"."PAR_ROW_ID"(+))
      39 - access("T23"."OWNER_CON_ID"="T11"."ROW_ID"(+))
      41 - access("T23"."PER_ADDR_ID"="T20"."ROW_ID"(+))
      43 - access("T23"."RTNG_DLR_ID"="T1"."PAR_ROW_ID"(+))
      45 - access("T23"."DLR_ID"="T4"."PAR_ROW_ID"(+))
      47 - access("T23"."PREF_SRV_DLR_ID"="T17"."PAR_ROW_ID"(+))
      49 - access("T23"."BILL_ACCNT_ID"="T18"."PAR_ROW_ID"(+))
      51 - access("T23"."OWNER_ACCNT_ID"="T21"."PAR_ROW_ID"(+))
      53 - access("T23"."OWNER_ACCNT_ID"="T6"."PAR_ROW_ID"(+))
      54 - access("T23"."PR_CON_ID"="T12"."ROW_ID"(+))
      56 - access("T23"."ROW_ID"="T15"."ASSET_ID"(+) AND "T23"."BU_ID"="T15"."BU_ID"(+))
      57 - access("T15"."BU_ID"="T13"."ROW_ID"(+))
      59 - access("T23"."ROOT_ASSET_ID"="T19"."ROW_ID"(+))
      61 - access("T19"."PROD_ID"="T2"."ROW_ID"(+))
      63 - access("T15"."BU_ID"="T5"."PAR_ROW_ID"(+))
      65 - access("T23"."ROW_ID"="T22"."PAR_ROW_ID"(+))
    
    Note
    -----
       - dynamic sampling used for this statement
    
    105 rows selected.

    Hello

    It is not necessary to display the trace file - everything is clear from the plans that you have posted. The optimizer is the selectivity calculation assuming the absence of correlation between the columns. You can do these calculations that yourself and you see that if the entries are correct and if the hypothesis of lack of correlation is also correct, then the results should be correct, too. Since they are not, it's one of two things: optimizer stats are wrong, or the columns are in fact related.

    First of all check the optimizer statistics: i.e. take NUM_ROWS and NUM_NULLS of DBA_TAB_COL_STATISTICS and compare them with the actual rowcounts. If they are correct (in a reasonable error margin), then it means that the columns are correlated, and the optimizer will need additional assistance to obtain right of cardinalities.

    Best regards
    Nikolai

  • need help with sql query dates

    Hello

    I have a sql query I need to extract some info between data dates. Where clause in this query is:

    WHERE CPD_BUS_UNIT =: ESI_PRM_1
    AND CPD_VOUCHER_DATE > =: P_DATE_FROM
    AND CPD_VOUCHER_DATE < (: P_DATE_TO + 1).

    When I run the query into a toad, I can view the data, but not the execution plan. It gives an error ORA-00932 inconsistent Datatypes.
    But when I remove (+ 1): P_DATE_TO, I can c the execution plan and data. The data will be different from the previous.

    Please suggest how to rewrite the query.

    Can you please give it a try?

    WHERE CPD_BUS_UNIT=:ESI_PRM_1
    AND CPD_VOUCHER_DATE >= :to_date(P_DATE_FROM)
    AND CPD_VOUCHER_DATE < (to_date(:P_DATE_TO)+1) 
    

    Concerning

  • Œuvres SQL query to MS SQL Server 2008, but not when you use the database kit

    I have this SQL query:

    DECLARE TABLE (@DataTypeTable)
    Name varchar (128).
    TypeID INT)

    -Add comma delimeted type data in the temporary table names
    INSERT INTO @DataTypeTable (name)
    SELECT * from WhatWeShouldDoRead.func_Split (@DataTypeTrimmed, ',')

    SELECT the name OF @DataTypeTable

    That takes a comma delimited by the string and returns the string as a table.  It works correctly in Microsoft SQL Server Management Studio.  When I run this as a stored procedure I return nothing.  There are no errors, SQL or otherwise.  I checked that I am connected to the correct database and the stored procedure is responsible without changing any error chain which is reported of this stored procedure (that code is not shown in the example above).  Has anyone seen this problem before, or have experience with SQL/Labview interfaces to tell me what I am doing wrong?

    Thanks in advance.


Maybe you are looking for