retrieve the records from the oracle sql query

Hello

I'm stuck with a requirement where I need to retrieve some recordset based on the conditions. I won't be able to produce the same data and table here, but I can explain the problem with the example statement:

If col2 contains 'y' to any folder, then select only the records. Where, as if no line contains the value 'y' for col2 then retrieve all records.

Database version: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64 bit Production

with temp (col1,col2)
as
(select level,decode(mod(level,2),0,'y',1,'n')
from dual
connect by level < 10)
select * from temp;

Please help, if possible through sql.

Thank you

Vikram

Something like below... Considered as non-null column col2...

with the temp (col1, col2)

as

(select level, decode (mod(level,2), 0, 'y', 1,' no))

of the double

connect by level<>

Select * from temp

WHERE col2 = NVL ((SELECT col2 FROM temp OÙ col2 = 'y' ET rownum = 1), col2);

Tags: Database

Similar Questions

  • 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

  • treatment of hierarchy in the oracle sql query

    I have two tables:

    The first contains COMPANY_ID and stuff
    The second contains stuff and PARENT_CATEGORY_ID

    I need to return a list containing COMPANY_ID and stuff. Entries, however, must come not only from the first table, but also include all the descendants of the second table.

    Thus, for example (and please read the example carefully) - Let's say in the first table, I have a line:

    COMPANY_ID | STUFF
    1000 | 1

    I have three rows in the second table:

    STUFF | PARENT_CATEGORY_ID
    1. null
    4: 1
    3. 2
    2: null

    I want to have the following accordingly:

    COMPANY_ID | STUFF
    1000 | 1
    1000 | 2
    1000 | 3


    How can I do this in oracle 10 in a single SQL statement?

    You can do this way:

    SQL> with t1 as(
      2  select 1000 COMPANY_ID, 1 CATEGORY_ID from dual),
      3  t2 as (select 1 CATEGORY_ID, to_number(null) PARENT_CATEGORY_ID from dual union
      4  select 2 , 1 from dual union
      5  select 3 , 2 from dual union
      6  select 4 , null from dual),
      7  -- end of test data
      8  t3 as (select category_id, connect_by_root category_id root_cat
      9  from t2
     10  start with t2.PARENT_CATEGORY_ID is null
     11  connect by prior t2.CATEGORY_ID = t2.PARENT_CATEGORY_ID)
     12  select t1.COMPANY_ID, t3.category_id
     13  from t1, t3
     14  where t1.category_id = t3.root_cat;
    
    COMPANY_ID CATEGORY_ID
    ---------- -----------
          1000           1
          1000           2
          1000           3
    

    Max
    [My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/31/le-direttive-di-compilazione-pragma/]

  • Skip and capture the Oracle SQL record dirty in a select statement

    Hello

    I have the Oracle Oracle 11.2.0.4 database when I run a select query.

    Question:

    10 columns have given Date format. When I try to execute this query into a FROG he says, a month not valid. Since the records are billion in nature, I am not able to know which line has this problem.

    Is there a way I can capture the failed row and add it to other tables and continues with the select statement regardless of this error

    OK, you have several TO_DATE functions fed a string that is built on the fly.  At least part of the time, the chain that is built does not match the date format mask used.

    For example:

    TO_DATE (SUBSTR (TO_CHAR (SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID), 0, 8). » -'|| SUBSTR (TO_CHAR (SQ_W_PURCH_CYCLNS_ORA. (LAST_SUBMITTED_ON_DTTM_WID), 9, 6), "YYYYMMDD-HH24MISS")

    "SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID' does not have a string where characters 5-6 are in the range 01-12.  You'll have to do an analysis on this column.  From its data and how that is managed by to_char.  What ARE the data type of ' SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID' and what is a typical value?

    As others have said, this is simply an impossibility for a column of a table to actually have invalid month (or day, or year, or hour or minute or second).  ONLY, you get this error during the conversion of a string to a date with the TO_DATE function.

  • Number displayed in the oracle.sql.NUMBER form in the result of the query

    Developer SQL version 3.2.10.09.57 displays numbers like "oracle.sql.NUMBER@66a35419 (the part after @ is not constant and change each time) even for simple count (*) select double."
    At the same time "run the Script (F5)" no indication that the header
    COUNT (*)
    ------------
    and no the query results.

    Hi Andriy,

    The forum search, I see a similar complaint noted against 3.1.07.42. Instruction execution produces the list oracle.sql.NUMBER, probably because of a corrupt installation query results (due to decompress questions, or perhaps no decompression in an empty directory). See the following thread:
    SQLDev 3.1: Number-fields in the tables have "oracle.sql.NUMBER @...". »

    Hope this helps,
    Gary
    SQL development team

  • Retrieve the backend SQL to Oracle Financials report

    Hello

    There is an updated report in place in Oracle Financials (Portal). It works via a concurrent program, how do I view the SQL backend behind the report

    Can anyone help?

    p.s. I use version 12

    Thank you

    Hello.
    The responsibility of the system administrator, query the report in the definitions of concurrent programs and check the enable Trace. Run the program. A trace file will be put on your $ORACLE_HOME/admin/udump directory. TKProf this trace file and open the generated output.

    I hope this helps.
    Octavio

  • A question about the Oracle SQL Developer Oracle instance connection

    Hi all

    I would be grateful if you could kindly give me a helping hand.

    Recently, I installed the Oracle 11 g on Linux (ubuntu 8.10) database. I not create startup scripts. So here's how I start the server: (my linux user name is "dariyoosh", but in order to start the server I have connection on the terminal shell as user 'oracle')
    dariyoosh@alborz:~$ su oracle
    Password: 
    oracle@alborz:/home/dariyoosh$ cd
    oracle@alborz:~$ ORACLE_SID=database01
    oracle@alborz:~$ . oraenv
    ORACLE_SID = [database01] ? 
    The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle
    oracle@alborz:~$ sqlplus '/as sysdba'
    ...
    SQL> STARTUP NOMOUNT
    ORACLE instance started.
    ...
    SQL> ALTER DATABASE MOUNT;
    ...
    SQL> ALTER DATABASE OPEN;
    
    Database altered.
    Then I can work without any problems with my database and everything works pretty well. Today, I decided to install Oracle SQL Developer IDE as it makes it easier to modify the SQL code. My problem is that after reading the tutorial Oracle online, that I am still able to connect to my database. Firstly according to the method that I wrote, I have set up the Oracle instance. But then when I run Oracle SQL Developer I don't know what to choose for the user name and password? because since SQL * Plus shell as you can see I always write: "sqlplus 'virtue sysdba' and it does not prompt me for any password, I can access the database directly." Any idea? What password? What user name? for Oracle SQL Developer?

    Thanks in advance.

    When you connect "/ as sysdba", you actually connect as the user named SYS from the privileges of your operating system. SYS is the owner of the database and a privileged user. You really want to use this username for the day to day operations, but only for what can do only SYS. If you need a different user name. Several Oracle databases have a user named SCOTT who has a number of tables for use tutorial. By default, the password for SCOTT's "Tiger." You may also have other demo users, such as "HR". I admit that I forgot what is the password of the HR, but it doesn't really matter because SYS can change with this command:

    ALTER USER hr IDENTIFIED BY whateveryouwant;
    

    This command:

    SELECT USERNAME FROM ALL_USERS;
    

    lists all the users in your database. Understand that many of these users are there as owners of objects such as stored procedures and tables for Application Express, or TYPEs for Oracle Locator, not for general use. When you are ready to create your own objects, ask SYS create a username for them with

    CREATE USER myusername IDENTIFIED BY mypassword;
    

    and grant that user the privileges as necessary. You'll want to read before you get too far - I think that the developer of the Application Guide is a good starting point.

  • Question to convert oracle sql query

    Hi friends,

    I have a sql query, as follows,
    Select Name From SysObjects Where XType = 'U' And Name = @Name
    I want to convert this to oracle. I tried to convert this in someways. But I get errors only. Please someone help me solve this problem.

    Thank you
    RAM

    Views of the Oracle dictionary more come in DBA_, ALL_ USER_ flavors. You probably don't have privileges to view DBA_OBJECTS, in which case try object or USER_OBJECTS.

    Of after what I read, you may need something like

    SELECT * FROM all_objects WHERE owner <> 'SYS' AND object_type = 'TABLE'
    

    BTW, a sure way to liquidate Oracle professionals is to use "SQL" to designate another DBMS product, not Structured Query Language. As you may have noticed, we have SQL here as well.

  • Oracle SQL query

    Hello

    I need a sql query that offers the real half and the previous semester using the effective date.

    Thanks in advance!

    October - March = > RESULT: WSYY/YY

    April - September = > RESULT: SSYY

    Example 1:

    Effective date: 15.05.2015

    Result:

    WS14/15

    SS15

    Example 2:

    Effective date: 27.02.2015

    Result:

    SS14

    WS14/15

    Example 3:

    Effective date: 12.07.2014

    Result:

    WS13/14

    SS14

    Hello

    You could just unpivot previous results.

    You can also do this way:

    WITH months_to_add AS

    (

    SELECT 0 n double AS UNION ALL

    SELECT - 6 DOUBLE

    )

    got_semester_date AS

    (

    SELECT t.actual_date

    ADD_MONTHS (t.actual_date, m.n) AS semester_date,

    CASE

    WHEN m.n = 0 THEN 'semester underway'

    ELSE 'previous semester.

    END AS Column1

    FROM table_x t

    CROSS JOIN months_to_add m

    )

    SELECT actual_date

    Column1

    CASE

    WHEN TO_CHAR (semester_date, 'MM') BETWEEN ' 04 "

    AND '09'

    THEN TO_CHAR (semester_date, "" SS"YY")

    Of OTHER TO_CHAR (ADD_MONTHS (semester_date-9)

    , '' WS' YY '.

    )

    ||  To_char (ADD_MONTHS (semester_date, 3))

    , ' / YY'

    )

    END AS Column2

    OF got_semester_date

    ORDER BY actual_date

    semester_date

    ;

  • For the CASE of the Oracle SQL statement problem

    Follwing query run without any problem in oracle 12 c.

    SELECT

       BOX to_number (sysdate ' on()

             WHEN 6 THEN to_char(sysdate,'ww')+1

             WHEN 2 THEN to_char(sysdate,'ww')+1 

             ELSE to_char(sysdate,'ww')+ 1 END 

             FROM dual

    But the request fails below. Only change is WHEN 6 THEN to_char (sysdate 'ww') + 2

    SELECT

       BOX to_number (sysdate ' on()

             WHEN 6 THEN to_char(sysdate,'ww')+2

             WHEN 2 THEN to_char(sysdate,'ww')+1 

             ELSE to_char(sysdate,'ww')+ 1 END 

             FROM dual


    Data fault is ORA-01722 invalid number

    Hello

    Try below.

    SELECT

    CASE to_number (to_char(sysdate,'D'))

    WHEN 6 THEN to_char (sysdate, "ww") + 2

    WHEN 2 THEN to_char (sysdate, "ww") + 1

    END of ANOTHER to_char (sysdate, "ww") + 1

    OF the double

  • Dynamic recovery for the dynamic sql query

    Hi all

    I want to create a query dynamically and to fetch it in a dynamic cursor record... The structure of the record should be the same as that of the query...
    Can you suggest any method to do this.

    for example

    OPEN < dynamic news > TO < dynamic stmt >;
    LOOP
    FETCH < dynamic news > < DYNAMIC rec >;
    ---
    END LOOP;
    CLOSE < dynamic news >;

    How to declare the rec here dynamic? I wouldn't have the columns in the query in advance either.

    Thank you
    Merz

    Published by: merz Sep 12, 2011 17:02

    Published by: merz Sep 12, 2011 17:03

    Merz says:

    How to declare the rec here dynamic? I wouldn't have the columns in the query in advance either.

    Is not possible. What you describe is called four dynamic sql type. For this type of synamic SQL, you use the DBMS_SQL package.

    SY.

  • Conditional display of interactive report based on the different SQL query

    Hello

    I have two drop-down list at the top of my page and below I have an interactive report.
    Based on the selection of the user from the drop-down list values, interactive report should change based on different SQL queries.

    Is it possible to have different SQL queries based on the drop-down list values and generate interactive report based on that?

    Thank you

    Hello

    You can't have IR based on function returning the query as you can have classic report

    But here is a workaround
    http://www.oracleapplicationexpress.com/tutorials/71

    Kind regards
    Jari

  • Fusion HCM SaaS - how to find screens behind VO &amp; the VO sql query

    In my view, it is not currently possible for a customer to find out this information in SaaS mode... is it?

    I wonder if there is a way we could get this information internally for a few big screens HCM. (for example, the various "Manage no one screens ')? This would make it much easier for partners, OCS & customers to write the new data in BI Publisher model and meet a number of needs reports not yet served by the areas delivered.

    Hi Kiran,

    the model of data (tables, views, etc.) are documented in the Fusion Apps OER (https://fusionappsoer.oracle.com), but is not necessarily you help understand how a particular screen derives its data.

    We have a few messages from blog out there that explain how to identify the code objects:

    https://blogs.Oracle.com/fadevrel/entry/finding_code_artifacts_for_customization

    https://blogs.Oracle.com/fadevrel/entry/finding_code_artifacts_for_customization1

    But I don't think that there is a way to achieve what you are looking for if you have access to an instance of SaaS.

  • The join SQL query help

    I'm just having a bit of troubel get a correct join query - I thought it was an Inner Join, but I don't get the results I expect.

    My table structure is:

    Table: lodges

    LodgeID (PK)

    Lodge

    etc.

    Table: implemented application

    NominationID (PK)

    Category

    LodgeID

    Year

    So I try to use this structure to replicate this page:

    http://www.safariawards.com/nominees12/

    That is to say a list of boxes for each category, they are appointed on.

    The query I've tried looks like this:

    SELECT appointments. LodgeID, lodges. Lodge, applications. NominationID, applications. Lodges INNER JOIN applications category IT lodges. LodgeID = nominated. NominationID WHERE category = "Best property of Safari in southern Africa" ORDER BY Lodge

    But this product:

    http://www.safariawards.com/nominees12/southernafrica.php

    Its the right number of results, but not the list on the right of the boxes - for example British Airwways is not LodgeID 786

    If anyone could help with the SQL right for what would be well appreciated.

    That you join on the wrong column. Try this:

    SELECT appointments. LodgeID, lodges. Lodge, applications. NominationID, applications. Lodges INNER JOIN applications category IT lodges. LodgeID = nominated. LodgeID WHERE category = "Best property of Safari in southern Africa" ORDER BY Lodge

  • Difference between the static SQL query and dynamic SQL query.

    Hello

    Please explain the fundamental difference between static and dynamic sql queries. Please explain for example.

    Static: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/static.htm
    Dynamics: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/dynamic.htm

Maybe you are looking for