SQL INTO union-clause

SQL help

If any of the queries Union returns a value, I would like to mark as closed status. How can I put the INTO clause in this case because of two queries. Thank you

BEGIN

SELECT 1

FROM TableA your
WHERE tA.col1 = 13
AND tA.col2 = '100'
UNION
SELECT 1
TB from TableA
WHERE tb.col2 = 'y '.
AND tb.col3 = - 123
AND tb.col4 IS NOT NULL;

status_cd: = 'closed ';

EXCEPTION
WHEN NO_DATA_FOUND THEN
status_cd: = 'Unknown ';

END;

Hello

Here's one way:

BEGIN

SELECT 'closed '.

IN status_cd

FROM tablea

WHERE ((col1 = 13

AND col2 = '100'

)

OR (col2 = 'y')

AND col3 = - 123

AND col4 IS NOT NULL

)

)

AND ROWNUM = 1;

EXCEPTION

WHEN NO_DATA_FOUND

THEN

status_cd: = 'Unknown ';

END;

Tags: Database

Similar Questions

  • How to eliminate the union clause

    I have a requirement where I need to get some recording (say 5 records) of the table and the sum (TOTAL) of some columns in these 5 folders that should be displayed as the last record. Im trying it work with union all clause

    Select cd
    pid
    dt
    number
    type
    sum (iamt) iamt
    sum (ALMPs) ALMPs
    sum (oamt) oamt
    idt
    from t1
    where code = 'NAQ.
    Group by cd, pid, dt, idt
    Union of all the
    Select 'TOTAL '.
    null
    null
    null
    null
    sum (iamt) iamt
    sum (ALMPs) ALMPs
    sum (oamt) oamt
    null
    from t1
    where code = 'NAQ;

    is there a way I can avoid using the UNION clause and achieve the same...? Kindly share your thoughts...

    Hello

    Try below:
    SELECT cd,
    nest,
    DT,
    NUMBER,
    TYPE,
    Sum (iAMT) iamt,
    Sum (ALMPS) ALMPs,
    Sum (OAMT) oamt,
    IDT
    FROM t1
    WHERE code = 'NAQ.
    GROUP BY GROUPING SETS ((dt, cd, pid, NUMBER, idt), NULL)

    Kind regards
    Karine

  • I need assistance of query SQL, a query to get the same without union clause

    EmpNo, ename sum (sal) sum (deptno)
    200-2000-10 Tom
    201 3000 10 smith
    Alfred 202 20 3000
    40 8000 total
    select NVL(TO_CHAR(employee_id), 'Total'),
           max(last_name),
           sum(salary),
           sum(department_id)
      from employees
     group by rollup(employee_id), ()
    
  • Help with SQL Loader when Clause

    I have 2 exact same structure Oracle tables.


    NUMBER OF ENO
    NUMBER OF PARENT
    NUMBER OF CHILDREN
    ENAME VARCHAR2 (50 bytes)
    ADDRESS VARCHAR2 (50 bytes)
    CITY VARCHAR2 (50 bytes)
    SRCFILENAME VARCHAR2 (50 bytes)
    SDATE VARCHAR2 (400 bytes)
    Current_Load VARCHAR2 (1 byte)




    Have a data file and a charger control file that loads data into these 2 tables.
    I need to make a conditional charge using a when clause.
    Condition: what MOTHER = CHILD, load table 2 other load in table 1

    My control file looks like this.
    LOAD DATA 
    INFILE 'TEST_20120815.txt' 
    APPEND INTO TABLE test1 
    fields terminated by "|" 
    trailing nullcols 
    ( 
    eno, 
    parent, 
    child, 
    ename, 
    address, 
    city , 
    sdate "to_date(:sdate,'DD/MM/YYYY')", 
    SrcFileName, 
    col7 filler, 
    "Current_Load" constant 'Y' 
    ) 
    INTO TABLE test2 when (parent=child) 
    fields terminated by "|" 
    trailing nullcols 
    ( 
    eno position(1), 
    parent, 
    child, 
    ename, 
    address, 
    city , 
    sdate "to_date(:sdate,'DD/MM/YYYY')", 
    SrcFileName, 
    col7 filler, 
    "Current_Load" constant 'Y' 
    ) 
    But it does not work. It works fine if I give a direct value like PARENT = 'P '.

    Any idea how compare the 2 fields while the conditional support?

    You can't compare 2 fields with the WHEN clause in SQL * file the charger control.
    only literal values as defined by the syntax:

    http://docs.Oracle.com/CD/B19306_01/server.102/b14215/ldr_control_file.htm#i1005657

    As already suggested, you'd be better to load data using an external table which allows to apply conditions you want in your SQL query, which is to get the data.

  • SQL Loader when Clause

    Hello

    I have a requirement to load a file and exclude lines on a column with a value where ID NOT LIKE ' % no data %'

    OPTIONS (SKIP = 3)

    DOWNLOAD THE DATA

    INFILE ' / home/test.csv '

    IN THE test TABLE

    TRUNCATE

    What ID do NOT LIKE ' % no data %'

    ' Surrounded FIELDS TERMINATED BY ',' possibly ' ' '

    TRAILING NULLCOLS

    (ID,

    BEGUN,

    TIME,

    DATE_ADDED SYSDATE

    )

    Some examples of ID:

    Data AVDFGHKL:no

    Data THGEIUJD:no

    The value will always point 10 a go (after the semi colon)

    I tried the following, but not luck

    When (1) = '1') AND (10:2). = 'No '.

    Yes, the outer table can be a better option (the file must be in the server). Depending on your data (i.e. the colon (:)) always comes in 9th place) it will work.)

    [oracle@localhost saubhik]$ cat my_data.txt
    AVDFGHKL:No Data, 09/11/2009
    JFDJFUJK, 09/11/2009
    AGHFJDKK:No Data, 09/11/2009
    TRUTIRUT, 09/11/2009
    [oracle@localhost saubhik]$ 
    
    [oracle@localhost saubhik]$ cat test_emp_ctl.ctl
    LOAD DATA
    INFILE 'my_data.txt'
    INTO TABLE test
    TRUNCATE
    when (9:9) <> ":"
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    (id, start_date DATE(19) "DD-MM-YYYY")
    [oracle@localhost saubhik]$ sqlldr scott/tiger control=test_emp_ctl.ctl
    
    SQL*Loader: Release 11.2.0.1.0 - Production on Tue Jun 2 16:20:22 2015
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 4
    [oracle@localhost saubhik]$ 
    

    Audit:

    SQL> SELECT * FROM test;
    
    ID                             START_DAT
    ------------------------------ ---------
    JFDJFUJK                       09-NOV-09
    TRUTIRUT                       09-NOV-09
    
    SQL> 
    
  • -SQL - GROUP BY clause: fields of nonaggregate mandate

    Hello

    I study data (especially data recovery) and found something interesting.

    When you use an aggregate function in the SELECT clause, it is mandatory to have all fields that are not aggregated in the SELECT clause to be there in the GROUP BY clause.
    For example,.

    SELECT dept_no, Salary
    The EMPLOYEE
    GROUP BY dept_no;

    The SQL above works fine.
    But what happens if the user forgets the dept_no in the GROUP BY clause or the clause GROUP BY itself is missing?
    Certainly, it is a mistake.

    Why this error is not handled by the database. I mean, the database must be smart/pretty smart to add the GROUP BY clause by itself. So let's assume that, if I miss the GROUP BY clause or miss a field no aggregated from the SELECT clause when I get at least an aggregate function on a field with at least a no aggregated field in the SELECT clause, the database should check the GROUP BY clause at compile time and add mandate missed the fields in the GROUP BY clause.

    Example,

    SQL1:_
    SELECT dept_no, Salary
    The EMPLOYEE
    GROUP BY dept_no;

    SQL2:_
    SELECT dept_no, Salary
    The EMPLOYEE;

    Here, the SQL1 and SQL2, both should give me same output without error.

    I can't understand why this is handled?

    Hello

    998478 wrote:
    ... If we mix the aggregated and non-aggregated values, then there must be a GROUP BY clause that contains all non-aggregated values. Why this is handled by the database/compiler itself?

    It IS managed by the compiler itself. The compiler manages to trigger an error. The compiler has no way of knowing if you want to remove something from the SELECT clause, or add something to the GROUP BY clause, or not to use the aggregate functions or use several aggregate functions, or a combination of the above. If the compiler re-writes your code and none of these things done automatically, it would be wrong more often that he was right, and you would (rightly) complain about his behavior.

    For example, it is clearly wrong:

    SELECT    deptno
    ,       job
    ,       SUM (sal)
    FROM       scott.emp
    GROUP BY  deptno
    ;
    

    What is the right way to fix it?

    1. remove something from the SELECT clause

    SELECT    deptno
    ,       SUM (sal)
    FROM       scott.emp
    GROUP BY  deptno
    ;
    

    2. add something to the GROUP BY clause

    SELECT    deptno
    ,       job
    ,       SUM (sal)
    FROM       scott.emp
    GROUP BY  deptno
    ,         job
    ;
    

    3. do not use aggregate functions

    SELECT    deptno
    ,       job
    ,       sal
    FROM       scott.emp
    ;
    

    4. use several aggregate functions

    SELECT    deptno
    ,       MIN (job)
    ,       SUM (sal)
    FROM       scott.emp
    GROUP BY  deptno
    ;
    

    What are all the options, either. For example, the correct solution would be to use analytical functions instead of aggregate functions.
    How can anyone tell which of them is right? They all have the right answer for some problem.

    Moreover, by saying that everying in the SELECT clause must be an aggregate or in the GROUP BY clause is a bit oversimplified.
    Fuller, here's the ABC of GROUP BY:
    When you use a GROUP BY clause or in an aggregate function, then all in the SELECT clause must be:
    (A) a ggregate function,
    (B) one of the expressions "group By."
    (C) adding to C, or
    (D) something that Depends on the foregoing. (For example, if you "GROUP BY TRUNC (dt)", you can SELECT "TO_CHAR (TRUNC (dt), 'Mon - DD')").

    Published by: Frank Kulash on April 13, 2013 13:44
    Additional code examples.

  • SQL Loader / WHAT clause / off swich? / bloated log files

    Hello everyone,

    I'm loading data using SQL-Loader very large source files. It all works very well.

    However, now, by using the WHEN clause (in the control file), I would like to only a very small subset of most load data. This also works very well...

    WHEN ARTICLECODE! '000000000000006769' =

    However, the log file becomes fully inflated with messages telling me to each record that does not have the WHEN clause...

    Record 55078: Discarded - failed all WHEN clauses.

    This becomes a problem because it slows down the process and creates large log files that eat upward of my disk space.

    There must be a simple command to allow me to disable the messages of thiese, but although I googled on it, I could not find it.

    Any ideas on this one? I don't know that it's simple.

    Best regards and many thanks,
    Alan Searle

    Try adding the SILENCE = RELEASES key sqlldr command

    Silent means - delete messages during execution (header, comments, errors, discards, partitions)

  • PL SQL conditional between clause

    I generate data based on certain criteria of dates as below:

    I need to apply the underside of the conditions in which my query clause.

    SYSDATE DATE of TRAN
    If SYSDATE = 8th monthTRAN_DATE between the 20th of the month previous , and the 7th of the month in course
    If SYSDATE = 20 of each monthTRAN_DATE between 8 current month and 19 month courses

    SELECT *
    FROM TABLE1
    WHERE TRAN_DATE ---------------------
    ;
    

    Hello

    Here's one way:

    WHERE tran_date > = CASE TO_CHAR (SYSDATE, 'DD')

    WHEN '08' THEN TRUNC (ADD_MONTHS (SYSDATE, 1))

    , 'MONTHS '.

    ) + 19

    WHEN '20' THEN TRUNC (SYSDATE

    , 'MONTHS '.

    ) + 7

    END

    AND tran_date< trunc="">

    If today is the 8th or the 20th of each month?

  • How to put more than 1,000 values into a clause IN Oracle

    Is it possible to work around the limitation of 1000 elements of static clause IN Oracle 10g? I have a list of delimited by commas of a large number of ID that I want to use an IN clause, most of the time values can exceed 5000. And I don't have the privileges to create a temporary table, so that I can put all those to whom and run at a time.

    Thank you
    Marwa

    Hello

    Select * from hogehoge where col1 in (1, 5000);

    -> error

    Select * from hogehoge where col1 in (1.1000) or col1 in (1001.2000) or col1 in (2001.3000) or col1 in (3001.4000) or col1 in (4001.5000);

    -> may be OK

    Kind regards

  • variable with sql reuse various clauses

    Hello

    Is it possible to reuse the same variable with sql different queries in the packages...

    Example:

    I have a Word to say variable

    name of the variable 1): filename

    (2) in variable query: select 'emp.txt' of the double

    so using the name of this variable in the data store, I'm passing filename dynamically, but I need to change the file name to dept.txt emp.txt missing emp.txt food.

    A solution on my side uses a table dump with the file name. more without the use of db tables

    Please share views

    See you soon,.
    Surya

    You will then need the help of beanshell java technology. Variable2 take the second query in cooling mode. Now, create a procedure. At the 1st step of technology will be java beanshell with below codes.

    <>
    String xtr = "#variable2";
    @>

    Now in ko-> step use variable1 in assign mode

    Variable1 =<@=xtr@>

    It will certainly work.

    Thank you.

  • Tuning sql (where order clauses)

    Hello

    This request is really slow, because it calls the function f to each line (table1 and table2 may have more than 10000 lines)

    SELECT * FROM table1 t1 inner join tabl2 t2..............
    WHERE where_clause_1
    AND where_clause_2
    AND f(t1.a, t2.a) = 'Y'
    

    Returns 20 lines

    Howerver, this query is much faster

    SELECT * FROM table1 t1 inner join tabl2 t2..............
    WHERE where_clause_1
    AND where_clause_2
    -- AND f(t1.a, t2.a) = 'Y'
    

    Returns 24 ranks

    I try that, but it is too slow:

    SELECT * FROM (
         SELECT ... FROM table1 t1 inner join tabl2 t2..............
         WHERE where_clause_1
         AND where_clause_2
    )
    WHERE f(t1_a, t2_a) = 'Y'
    

    I would like to SELECT by where_clause_1 filter then where_clause_2 and finally the function call.

    How can I do?

    Thank you!

    1. SELECT * FROM)
    2. SELECT / * + NO_MERGE * /... THE T1 from table1 inner join t2 tabl2...
    3. WHERE where_clause_1
    4. AND where_clause_2
    5. )
    6. WHERE f (t1_a, t2_a) = 'Y '.

    Indicates tips NO_MERGE optimizer outer query not combine and query the view of inline in a unique.

  • Re: adding existing Union to seeded VO clause

    Hi all

    We have an obligation to add the union clause to existing VO which is a standard... Please help me if it is possible...

    Kind regards
    Rambaud.

    Rambaud,

    Except extending the VO, is there any method to set it programmatically ? 
    

    Laughing out loud

    Kind regards
    GYAN

  • How to handle multiple formats of date to the same date field in SQL * Loader

    Dear all,

    I have a requirement where I need to get data from a text file and even insert into the oracle table.

    I'm using SQL * Loader to fill data from the text file in my table.

    The file has an area where I expect to date data date in different formats, such as MON/dd/yyyy mon/dd/yyyy mon/dd/yyyy, dd/mm/yyyy, DD/month/yyyy.

    When you use SQL * Loader, I can see loading fails for records where we have formats such as LUN/jj/aaaa, Mon/dd/yyyy, DD/month/yyyy.

    Is it possible in SQL * Loader where we can mention all these date formats so that data from that date should go smoothly in the underlying date column in the table.

    Receive your answer on that.

    Thank you
    Madhu K.

    I think following could be the solution to your problem:

    Suppose if you have data from four different date formats, you need to load the data into four different tables by running SQL * Loader four times and each time specify other date format in the control file whose data to load, and then at the end, merge data from these four different tables using the UNION clause.

    Elya

  • SQL Loader - ignore the lines with "rejected - all null columns."

    Hello

    Please see the attached log file. Also joined the table creation script, data file and the bad and throw the files after execution.

    Sqlldr customer in the version of Windows-

    SQL * Loader: release 11.2.0.1.0 - Production

    The CTL file has two clauses INTO TABLE due to the nature of the data. The data presented are a subset of data in the real world file. We are only interested in the lines with the word "Index" in the first column.

    The problem we need to do face is, according to paragraph INTO TABLE appears first in the corresponding CTL lines file to the WHEN CLAUSE it would insert and the rest get discarded.

    1. statement of Create table : create table dummy_load (varchar2 (30) name, number, date of effdate);

    2. data file to simulate this issue contains the lines below 10. Save this as name.dat. The intention is to load all of the rows in a CTL file. The actual file would have additional lines before and after these lines that can be discarded.

    H15T1Y Index | 2. 19/01/2016 |

    H15T2Y Index | 2. 19/01/2016 |

    H15T3Y Index | 2. 19/01/2016 |

    H15T5Y Index | 2. 19/01/2016 |

    H15T7Y Index | 2. 19/01/2016 |

    H15T10Y Index | 2. 19/01/2016 |

    CPDR9AAC Index | 2. 15/01/2016 |

    MOODCAVG Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    3. the CTL file - name.ctl

    DOWNLOAD THE DATA

    ADD

    IN THE TABLE dummy_load

    WHEN (09:13) = "Index".

    TRAILING NULLCOLS

    (

    COMPLETED name BY ' | ',.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    IN THE TABLE dummy_load

    WHEN (08:12) = "Index".

    TRAILING NULLCOLS

    (

    COMPLETED name BY ' | ',.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    invoke SQL loader in a file-> beats

    C:\Oracle\product\11.2.0\client\bin\sqlldr USERID = myid/[email protected] CONTROL=C:\temp\t\name.ctl BAD=C:\temp\t\name_bad.dat LOG=C:\temp\t\name_log.dat DISCARD=C:\temp\t\name_disc.dat DATA=C:\temp\t\name.dat

    Once this is run, the following text appears in the log file (excerpt):

    Table DUMMY_LOAD, charged when 09:13 = 0X496e646578 ('Index' character)

    Insert the option in effect for this table: APPEND

    TRAILING NULLCOLS option in effect

    Column Position Len term Encl. Datatype name

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

    NAME                                FIRST     *   |       CHARACTER

    RATE                                 NEXT     *   |       CHARACTER

    EFFDATE NEXT * |       CHARACTER

    SQL string for the column: ' TO_DATE (: effdate, "MM/DD/YYYY").

    Table DUMMY_LOAD, charged when 08:12 = 0X496e646578 ('Index' character)

    Insert the option in effect for this table: APPEND

    TRAILING NULLCOLS option in effect

    Column Position Len term Encl. Datatype name

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

    NAME                                 NEXT     *   |       CHARACTER

    RATE                                 NEXT     *   |       CHARACTER

    EFFDATE NEXT * |       CHARACTER

    SQL string for the column: ' TO_DATE (: effdate, "MM/DD/YYYY").

    Record 1: Ignored - all null columns.

    Sheet 2: Cast - all null columns.

    Record 3: Ignored - all null columns.

    Record 4: Ignored - all null columns.

    Sheet 5: Cast - all null columns.

    Sheet 7: Discarded - failed all WHEN clauses.

    Sheet 8: Discarded - failed all WHEN clauses.

    File 9: Discarded - failed all WHEN clauses.

    Case 10: Discarded - failed all WHEN clauses.

    Table DUMMY_LOAD:

    1 row loaded successfully.

    0 rows not loaded due to data errors.

    9 lines not loading because all WHEN clauses were failed.

    0 rows not populated because all fields are null.

    Table DUMMY_LOAD:

    0 rows successfully loaded.

    0 rows not loaded due to data errors.

    5 rows not loading because all WHEN clauses were failed.

    5 rows not populated because all fields are null.


    The bad file is empty. The discard file has the following

    H15T1Y Index | 2. 19/01/2016 |

    H15T2Y Index | 2. 19/01/2016 |

    H15T3Y Index | 2. 19/01/2016 |

    H15T5Y Index | 2. 19/01/2016 |

    H15T7Y Index | 2. 19/01/2016 |

    CPDR9AAC Index | 2. 15/01/2016 |

    MOODCAVG Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |

    H15TXXX Index | 2. 15/01/2016 |


    Based on the understanding of the instructions in the CTL file, ideally the first 6 rows will have been inserted into the table. Instead the table comes from the line 6' th.

    NAMERATEEFFDATE
    H15T10Y Index2January 19, 2016



    If the INTO TABLE clauses were put in the CTL file, then the first 5 rows are inserted and the rest are in the discard file. The line 6' th would have a ""rejected - all columns null. "in the log file. "


    Could someone please take a look and advise? My apologies that the files cannot be attached.

    Unless you tell it otherwise, SQL * Loader assumes that each later in the table and what clause after the first back in the position where the previous left off.  If you want to start at the beginning of the line every time, then you need to reset the position using position (1) with the first column, as shown below.  Position on the first using is optional.

    DOWNLOAD THE DATA

    ADD

    IN THE TABLE dummy_load

    WHEN (09:13) = "Index".

    TRAILING NULLCOLS

    (

    name POSITION (1) TERMINATED BY ' | '.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

    IN THE TABLE dummy_load

    WHEN (08:12) = "Index".

    TRAILING NULLCOLS

    (

    name POSITION (1) TERMINATED BY ' | '.

    rate TERMINATED BY ' | '.

    COMPLETED effdate BY ' | '. ' TO_DATE (: effdate, "MM/DD/YYYY").

    )

  • Optimization of queries OR clause

    I'm using Oracle 12.1.0.2.

    I have a given below request that has 2 predicate with OR condition that contains text search in 2 tables (eir and eir_notes).    It takes 20 seconds.   The Charly come back in the second if I run the query with a single predicate without the GOLD clause.    Therefore, I solved it by the union to place where. I've included the two sql with the explain plan below command.

    Just for my knowledge, is there advice that I could use to make sql in OR more fast?

    Slow SQL with OR:

    SQL TEXT:

    SELECT  /*+ gather_plan_statistics
    */
          COUNT (*)
      FROM   (SELECT   eir.actn_tx
                FROM   EXAM_INCDT_RPT eir
               WHERE   (   contains (eir.prblm_tx, :1) > 0
                        OR eir.exam_incdt_rpt_id IN (SELECT /*+ qb_name( qb_sub_note)    */
                                                           exam_incdt_rpt_id
                                                       FROM   eir_note
                                                      WHERE   contains (note_tx, :2) > 0)))
    

    SQL_ID  8rwvqyphavc0c, child number 1
    -------------------------------------
    SELECT  /*+ gather_plan_statistics  */   COUNT (*)   FROM   (SELECT  
    eir.actn_tx              FROM   EXAM_INCDT_RPT eir            WHERE     
                       (   contains (eir.prblm_tx, :1) > 0 OR               
               eir.exam_incdt_rpt_id IN (SELECT /*+ qb_name( qb_sub_note)   
     */                                                          
    exam_incdt_rpt_id                                                       
     FROM   eir_note                                                       
    WHERE   contains (note_tx, :2) > 0)                                     
                      ))
    
    Plan hash value: 2956686415
    
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                             | Name           | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers | Reads  |
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                      |                |      1 |        |       |  1343K(100)|          |      1 |00:00:20.24 |    1467K|   6770 |
    |   1 |  SORT AGGREGATE                       |                |      1 |      1 |   105 |            |          |      1 |00:00:20.24 |    1467K|   6770 |
    |*  2 |   FILTER                              |                |      1 |        |       |            |          |   5419 |00:00:21.28 |    1467K|   6770 |
    |   3 |    TABLE ACCESS FULL                  | EXAM_INCDT_RPT |      1 |    447K|    44M|  1343K  (1)| 00:01:45 |    447K|00:00:00.69 |    5819 |   5816 |
    |*  4 |    TABLE ACCESS BY INDEX ROWID BATCHED| EIR_NOTE       |    441K|      1 |   273 |     6   (0)| 00:00:01 |      2 |00:00:02.48 |     567K|    226 |
    |*  5 |     INDEX RANGE SCAN                  | EIR_NOTE_IX1   |    441K|      1 |       |     1   (0)| 00:00:01 |  10753 |00:00:01.65 |     535K|     20 |
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Query Block Name / Object Alias (identified by operation id):
    -------------------------------------------------------------
    
       1 - SEL$F5BB74E1
       3 - SEL$F5BB74E1 / EIR@SEL$2
       4 - QB_SUB_NOTE  / EIR_NOTE@QB_SUB_NOTE
       5 - QB_SUB_NOTE  / EIR_NOTE@QB_SUB_NOTE
    
    Outline Data
    -------------
    
      /*+
          BEGIN_OUTLINE_DATA
          IGNORE_OPTIM_EMBEDDED_HINTS
          OPTIMIZER_FEATURES_ENABLE('12.1.0.2')
          DB_VERSION('12.1.0.2')
          OPT_PARAM('_optim_peek_user_binds' 'false')
          ALL_ROWS
          OUTLINE_LEAF(@"QB_SUB_NOTE")
          OUTLINE_LEAF(@"SEL$F5BB74E1")
          MERGE(@"SEL$2")
          OUTLINE(@"QB_SUB_NOTE")
          OUTLINE(@"SEL$1")
          OUTLINE(@"SEL$2")
          FULL(@"SEL$F5BB74E1" "EIR"@"SEL$2")
          PQ_FILTER(@"SEL$F5BB74E1" SERIAL)
          INDEX_RS_ASC(@"QB_SUB_NOTE" "EIR_NOTE"@"QB_SUB_NOTE" ("EIR_NOTE"."EXAM_INCDT_RPT_ID"))
          BATCH_TABLE_ACCESS_BY_ROWID(@"QB_SUB_NOTE" "EIR_NOTE"@"QB_SUB_NOTE")
          END_OUTLINE_DATA
      */
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter(("CTXSYS"."CONTAINS"("EIR"."PRBLM_TX",:1)>0 OR  IS NOT NULL))
       4 - filter("CTXSYS"."CONTAINS"("NOTE_TX",:2)>0)
       5 - access("EXAM_INCDT_RPT_ID"=:B1)
    
    Column Projection Information (identified by operation id):
    -----------------------------------------------------------
    
       1 - (#keys=0) COUNT(*)[22]
       3 - "EIR".ROWID[ROWID,10], "EIR"."EXAM_INCDT_RPT_ID"[NUMBER,22], "EIR"."PRBLM_TX"[LOB,4000]
       5 - "EIR_NOTE".ROWID[ROWID,10]
    

    Explain the plan of sql with union

    SQL TEXT:

    SELECT /*+ gather_plan_statistics */
          COUNT (*)
      FROM   (SELECT   *
                FROM   EXAM_INCDT_RPT eir
               WHERE   contains (eir.prblm_tx, :1) > 0
              UNION ALL
              SELECT   *
                FROM   EXAM_INCDT_RPT
               WHERE   exam_incdt_rpt_id IN (SELECT   exam_incdt_rpt_id
                                               FROM   eir_note
                                              WHERE   contains (note_tx, :2) > 0))
    
    
    

    The use_concat flag may be appropriate.

    https://docs.Oracle.com/database/121/SQLRF/sql_elements006.htm#BABIAFIB

    The USE_CONCAT index tells the optimizer to transform handset OR -the economic situation in the WHERE clause of a query in a composite application using the UNION ALL fixed operator. Without this indication, this transformation only occurs if the query using concatenations is less expensive than the cost without them. The USE_CONCAT Council overrides consideration of cost. For example:

    SELECT /*+ USE_CONCAT */ * FROM employees e WHERE manager_id = 108 OR department_id = 110;
    

Maybe you are looking for

  • HP ENVY laptop - 15-k220nr: upgraded wireless HP ENVY laptop-15 k220nr.

    Hello My laptop came with Intel AC card 3160 WiFi, but it is buggy and fall on and outside. I think of him replacing Intel AC 7260, which should be better. http://www.Amazon.com/Intel-7260-HMWG-R-Wireless-AC-Bluetooth-mounting/DP/B00MY9S692/ref=sr_1_

  • Query the number of channels on all devices

    I would like to know the total number of channels WAS supported by all the devices I plugged into my computer. The snippet of code below works, but it requires me to specify the device with a constant, or a control. When I go to create this constant/

  • PROBLEM UPDATING WINDOWS XP PACK 2 & 3!

    My HP laptop crashed last week, it was repaired. They added more memory and reloaded Windows XP. I had 48 automatic updates from microsoft, they have installed. I'm having a problem with 1-(NET Framework 1.0 Service Pack 3, English Version), does not

  • Backup windows XP home version 2002

    How can I save all the information on my computer, windows xp home version 2002. I went to start, programs, accessories, System Tools, but the option to save is not there? Please I need help ASAP before my copmputer crashes.

  • AVG 2011 problem after 4 days of use got broken!

    Hello, I would like to have help please. My computer hp compaq nc6220 laptop has a named AVG 2011 antivirus which I use several years ago. After formatting my laptop, I install the first device controller and other antivirus in the laptop and it is n