the use or condition in multiple-column subquery SQL

Hi team,

I need this accountability manual analysis between two tables in an easier way. These tables do not have a direct relationship.

Please find below the scripts to create table, insert data with the incorrect select query, I.,

CREATE TABLE TEST1)
KEY_PRM VARCHAR (30),
NOM_LISTE VARCHAR (30),
TEL_NO VARCHAR (10),
DATE OF CREATE_DT,
DATE OF CEASE_DT,
STATUS VARCHAR (20) - VALUE USED EITHER A OR C
);

CREATE TABLE TEST2)
KEY_PRM1 VARCHAR (30),
TEL_NO VARCHAR (20),
DATE OF TRANS_DATE,
TRANS_TYPE VARCHAR (20) / * VALUE USED ARE the INSERT, CEASE (Many others) * /.
);

INSERT INTO TEST1 (KEY_PRM, NOM_LISTE, TEL_NO, CREATE_DT, CEASE_DT, STATUS) VALUES ('1 ', 'SAM', '0123456789',' 01-APR-2013', NULL, 'A');
INSERT INTO TEST1 (KEY_PRM, NOM_LISTE, TEL_NO, CREATE_DT, CEASE_DT, STATUS) VALUES('2','MARS','0123456789','10-APR-2013','12-APR-2013','C');
INSERT INTO TEST1 (KEY_PRM, NOM_LISTE, TEL_NO, CREATE_DT, CEASE_DT, STATUS) VALUES('3','PLUTO','0123456799','05-APR-2013',,'A');
INSERT INTO TEST1 (KEY_PRM, NOM_LISTE, TEL_NO, CREATE_DT, CEASE_DT, STATUS) VALUES ('4 ', 'MAN', '0123456999',' 06-APR-2013', NULL, 'A');
INSERT INTO TEST1 (KEY_PRM, NOM_LISTE, TEL_NO, CREATE_DT, CEASE_DT, STATUS) VALUES('6','JIN','0123456999','06-APR-2013','08-APR-2013','C');
INSERT INTO TEST1 (KEY_PRM, NOM_LISTE, TEL_NO, CREATE_DT, CEASE_DT, STATUS) VALUES('7','RIM','0123456789','20-APR-2013',,'A');
INSERT INTO TEST1 (KEY_PRM, NOM_LISTE, TEL_NO, CREATE_DT, CEASE_DT, STATUS) VALUES('8','JIM','0123456789','12-APR-2013','12-APR-2013','C');
COMMIT;

INSERT INTO TEST2 (TEL_NO, TRANS_DATE, KEY_PRM1, TRANS_TYPE) VALUES('10','0123456789','01-APR-2013','INSERT');
INSERT INTO TEST2 (TEL_NO, TRANS_DATE, KEY_PRM1, TRANS_TYPE) VALUES('11','0123456789','12-APR-2013','CEASE');
INSERT INTO TEST2 (TEL_NO, TRANS_DATE, KEY_PRM1, TRANS_TYPE) VALUES('12','0123456799','12-APR-2013','INSERT');
INSERT INTO TEST2 (TEL_NO, TRANS_DATE, KEY_PRM1, TRANS_TYPE) VALUES('13','0123456999','06-APR-2013','INSERT');
COMMIT;

SELECT T1. KEY_PRM, T1. STATUS, T1. CREATE_DT, T1. TEST1 T1 CEASE_DT WHERE
(T1.TEL_NO, (T1. CREATE_DT OR T1. CEASE_DT)) IN (SELECT T2.TEL_NO, T2. TRANS_DATE of TEST2 T2 where TRANS_TYPE in ('INSERT', 'END');

/ * T1 SHOULD PRODUCE RESULTS. KEY_PRM = 1,2,4,6,8. * /


There are two tables T1 TEST1 and TEST2 T2 having only matching column as TEL_NO but with many duplicates in both tables.

Results of the query to produce T1. KEY_PRM of TEST1 T1 where CONDITION 1 and CONDITION 2 game

CONDITION 1:-MATCH T1.TEL_NO WITH T2.TEL_NO
CONDITION 2:-BE T1. CREATE_DT OR T1. CEASE_DT CORRESPONDENCE WITH T2. TRANS_DATE.


Also kindly to me if it is not possible to create this select query?

l

Published by: a friend on April 11, 2013 01:21

Published by: a friend on April 11, 2013 01:22

This forum is dedicated to the support of the SQLDeveloper tool, to get answers more quickly for this kind of pure questions of SQL, you use the SQL and PL/SQL forum:

SQL and PL/SQL

Please repost it and mark this question as answered.

Tags: Database

Similar Questions

  • OR using condition in multiple-column subquery SQL

    Hi team,

    I need this accountability manual analysis between two tables in an easier way. These tables do not have a direct relationship.

    Please find below the scripts to create table, insert data with the incorrect select query, I.,
    CREATE TABLE TEST1 (
    KEY_PRM VARCHAR(30),
    LIST_NAME VARCHAR(30),
    TEL_NO VARCHAR(10),
    CREATE_DT DATE,
    CEASE_DT DATE,
    STATUS VARCHAR(20) --VALUE USED EITHER A OR C
    );
    
    CREATE TABLE TEST2(
    KEY_PRM1 VARCHAR(30),
    TEL_NO VARCHAR(20),
    TRANS_DATE DATE,
    TRANS_TYPE VARCHAR(20)/*VALUE USED ARE INSERT,CEASE(Many others)*/
    );
    
    INSERT INTO TEST1 (KEY_PRM,LIST_NAME,TEL_NO,CREATE_DT,CEASE_DT,STATUS) VALUES('1','SAM','0123456789','01-APR-2013',NULL,'A');
    INSERT INTO TEST1 (KEY_PRM,LIST_NAME,TEL_NO,CREATE_DT,CEASE_DT,STATUS) VALUES('2','MARS','0123456789','10-APR-2013','12-APR-2013','C');
    INSERT INTO TEST1 (KEY_PRM,LIST_NAME,TEL_NO,CREATE_DT,CEASE_DT,STATUS) VALUES('3','PLUTO','0123456799','05-APR-2013',NULL,'A');
    INSERT INTO TEST1 (KEY_PRM,LIST_NAME,TEL_NO,CREATE_DT,CEASE_DT,STATUS) VALUES('4','MAN','0123456999','06-APR-2013',NULL,'A');
    INSERT INTO TEST1 (KEY_PRM,LIST_NAME,TEL_NO,CREATE_DT,CEASE_DT,STATUS) VALUES('6','JIN','0123456999','06-APR-2013','08-APR-2013','C');
    INSERT INTO TEST1 (KEY_PRM,LIST_NAME,TEL_NO,CREATE_DT,CEASE_DT,STATUS) VALUES('7','RIM','0123456789','20-APR-2013',NULL,'A');
    INSERT INTO TEST1 (KEY_PRM,LIST_NAME,TEL_NO,CREATE_DT,CEASE_DT,STATUS) VALUES('8','JIM','0123456789','12-APR-2013','12-APR-2013','C');
    COMMIT;
    
    INSERT INTO TEST2 (KEY_PRM1,TEL_NO,TRANS_DATE,TRANS_TYPE) VALUES('10','0123456789','01-APR-2013','INSERT');
    INSERT INTO TEST2 (KEY_PRM1,TEL_NO,TRANS_DATE,TRANS_TYPE) VALUES('11','0123456789','12-APR-2013','CEASE');
    INSERT INTO TEST2 (KEY_PRM1,TEL_NO,TRANS_DATE,TRANS_TYPE) VALUES('12','0123456799','12-APR-2013','INSERT');
    INSERT INTO TEST2 (KEY_PRM1,TEL_NO,TRANS_DATE,TRANS_TYPE) VALUES('13','0123456999','06-APR-2013','INSERT');
    COMMIT;
    
    SELECT T1.KEY_PRM,T1.STATUS,T1.CREATE_DT,T1.CEASE_DT FROM TEST1 T1 WHERE
    (T1.TEL_NO,(T1.CREATE_DT OR T1.CEASE_DT)) IN (SELECT T2.TEL_NO,T2.TRANS_DATE from TEST2 T2 where TRANS_TYPE in ('INSERT','CEASE');
    
    /*RESULTS SHOULD PRODUCE T1.KEY_PRM = 1,2,4,6,8.*/
    There are two tables T1 TEST1 and TEST2 T2 having only matching column as TEL_NO but with many duplicates in both tables.

    Results of the query to produce T1. KEY_PRM of TEST1 T1 where CONDITION 1 and CONDITION 2 game
    CONDITION 1:- T1.TEL_NO MATCH WITH T2.TEL_NO
    CONDITION 2:- EITHER T1.CREATE_DT OR T1.CEASE_DT MATCH WITH T2.TRANS_DATE.
    Also kindly to me if it is not possible to create this select query?

    Published by: BluShadow on April 11, 2013 09:42
    addition of {noformat}
    {noformat} tags for readability.  Please read {message:id=9360002} and learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    You can use EXISTS

    SELECT T1.KEY_PRM,T1.STATUS,T1.CREATE_DT,T1.CEASE_DT
    FROM TEST1 T1
    WHERE exists
        (
         SELECT  NULL
             from TEST2 T2
         where t2.TRANS_TYPE in ('INSERT','CEASE')
         AND T2.TEL_NO = T1.TEL_NO
         AND T2.TRANS_DATE IN (T1.CREATE_DT,T1.CEASE_DT)
        );
    
  • Guidelines for the use of conditional text

    I'm looking for instructions on the use of conditional text. Our company has grown, and that the range of products has increased, the number of conditional text tags has increased. We are up to 30 tags and continues to grow. I was struck my colleague to start breaking this system a bit, because I'm afraid, it becomes a House of cards. Colleague has been 20 years and grew up with the system - it's the only one that it is used. He sees nothing wrong with it. The tags are in its abbreviation. When I mentioned that everybody don't would not new understand them, his response was that they would teach them eventually. Also, it's starting to get to the point where some sentences are be mislabeled, causing many errors.

    Are there guidelines I refer who say in the use of conditional text is too large so that it's not just my word? 


    Milmacrose

    You might want to take a look at Matt Sullivan & Sarah O'Keefe book (edition Fundamentals - unstructured FrameMaker 11; Chapter 24) for some background information on the consequences of the use of the multiple conditional tags. Depending on what your choice (i.e. to hide or show content based on the condition tag), you can get in very complex situations with some items possibly requiring each combination of tags applied to prevent display (or display) as needed. Even with simple simple conditional tags, it can reach a very large number of unique tags required (mathematically, you are summing a series of combinations). For example, [as used in the Book], given a product in Light versions, Standard and Pro with specific online requirements & Print for Mac, Windows and Unix, there are 32 conditional tags applied correctly. If you have content that should appear in a few versions, it climbs easily up to 47 unique tags. You'd be better trying to herd a bunch of cats in a field of grass cat...

  • Need help with the use of conditions in the correspondence management

    Hello

    Could someone please provide me with any tutorials or tips on the use of conditions in the correspondence management.

    Thank you.

    http://help.Adobe.com/en_US/enterpriseplatform/10.0/CorrespondenceManagementSolution/WS6db 1f95d7f6c954f-27f2691012b7fafb54f - 7ffe.html

  • to display the separted by commas in multiple columns

    Hello


    I want to display the value in multiple columns like below

    data like this

    col1

    res_menaHome:MenaHome
    res_menaHomeEmp:MenaHome used
    res_MDSpecialSer:MD Special Services
    res_Smart: Smart

    now, I want to display like

    col1 col2
    res_menaHome MenaHome
    res_menaHomeEmp employee MenaHome
    res_MDSpecialSer® Special Services
    chip res_Smart


    Thanks in advance.

    You mean like this?

    with q as (select 'res_menaHome:MenaHome' myString from dual)
    select substr(myString, 1, instr(myString, ':') - 1) col1,
    substr(myString, instr(myString, ':') + 1) col2
     from q
    
    COL1,COL2
    res_menaHome,MenaHome
    
  • The use of bind variables (in & out) with sql dynamic

    I have a table that contains code snippets to make postings on a set of pl/sql database. what the code does is basically receives an ID and returns a number of errors found.
    To run the code, I use dynamic sql with two bind variables.

    When codes consists of a simpel query, it works like a charm, for example with this code:
    BEGIN
       SELECT COUNT (1)
       INTO :1
       FROM articles atl
       WHERE ATL.CSE_ID = :2 AND cgp_id IS NULL;
    END;
    However when I get to post more complexes that must perform calculations or run several queries I run into trouble.
    I have boiled down the problem into that:
    DECLARE
       counter   NUMBER;
       my_id     NUMBER := 61;
    BEGIN
       EXECUTE IMMEDIATE ('
          declare 
             some_var number;
          begin
          
          select 1 into some_var from dual
          where :2 = 61; 
          
          :1 := :2;
          end;
    ')
          USING OUT counter, IN my_id;
    
       DBMS_OUTPUT.put_line (counter || '-' || my_id);
    END;
    This code is not really make sense, but it's just to show you what is the problem. When I run this code, I get the error
    ORA-6537 ON bind variable linked to a position IN

    The error doesn't seem wise,: 2 is the only one IN bind variable and it is only used in a where clause clause.
    As soon as I remove this where clause, the code works again (giving me 61-61, in case you want to know).

    Any idea what goes wrong? I just use bind variables in a way that you're not supposed to use it?

    I'm using Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit

    Correction. With immediate execution , the binding is in position, but binds do not need to be repeated. My statement above is incorrect...

    You must link only once - but bind by position. And the connection must correspond to the use of the variable binding.

    If the connection never variable assigns a value in the code, link by in.

    If the binding variable assigns a value in the code, link as OUTPUT.

    If the binding variable assigns a value and is used a variable in another statement in the code, link as IN OUT.

    For example

    SQL> create or replace procedure FooProc is
      2          cnt     number;
      3          id      number := 61;
      4  begin
      5          execute immediate
      6  'declare
      7          n       number;
      8  begin
      9          select
     10                  1 into n
     11          from dual
     12          where :var1 = 61;       --// var1 is used as IN
     13
     14          :var2 := n * :var1;     --// var2 is used as OUT and var1 as IN
     15          :var2 := -1 * :var2;    --// var2 is used as OUT and IN
     16  end;
     17  '
     18          using
     19                  in out id, in out cnt;  --// must reflect usage above
     20
     21          DBMS_OUTPUT.put_line ( 'cnt='||cnt || ' id=' || id);
     22  end;
     23  /
    
    Procedure created.
    
    SQL>
    SQL> exec FooProc
    cnt=-61 id=61
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • The use of div to create columns

    Hello

    I created (or attempt) to create a page with three colum with the div tag It seems OK except when I add content (or delete) to the div in right and left it mesess upward.

    Here is the link to the page

    http://www.dealfindit.com/productadpc.php?ProductID=211959635

    As soon as there is no content in the right Division moves the Center div. What is the best way to create a correct page of three columns with div I can't use the table that I use for the content div. Center repeat region

    Here is the code:

    css code
    =========
    
    #headlines{
     float: left;
     width: 15%;
     border-right: 1px solid #cccccc;
     border-bottom: 1px solid #cccccc;
    }
    #headlines2{
     float: right;
     width: 15%;
     
     border-left: 1px solid #cccccc;
     border-bottom: 1px solid #cccccc;
    }
    #headlines{
     margin: 0px;
     padding: 2px 0px 2px 2px;
     /*font-size: 80%;*/
    }
    
    #headlines2{
     margin: 0px;
     padding: 2px 2px 2px 0px;
     /*font-size: 80%;*/
    }
    
    
    
    

    First and foremost -.

    Styles of club with the same ID together as follows:

    #headlines{ float: left; width: 15%; border-right: 1px solid #cccccc; border-bottom: 1px solid #cccccc; margin: 0px; padding: 2px 0px 2px 2px; /*font-size: 80%;*/
    
    }#headlines2{ float: right; width: 15%;  border-left: 1px solid #cccccc; border-bottom: 1px solid #cccccc; margin: 0px; padding: 2px 2px 2px 0px; /*font-size: 80%;*/
    
    }
    

    then add a style for your average main content div too... something like:

    #mainContent {}
    Width: 68%;
    margin-left: 16%;
    margin-right: 16%;
    }

    Since each div left and right is 15%, I added 1% on either side to give some space (16%) and the width of 68% mainContent DIV (with additional 1% margins and padding already defined and all you may need to cut a little more... say 67 or 66%).

    and in html, you can have:

    Left content side comes here

    main central section comes here

    So, even if it stretches not no content in the left and right divs, the central section and should in place.

    Kind regards

    Vinay

  • Query to check the use of ASM on multiple servers

    Is there information contained in the database of grid control I can query to find the total size and uses the space for the ASM instances?  I'm on Cloud control 12.1.0.2 and monitoring 25 + servers all with ASM instances.  We alert that will send notifications when they reach a certain percentage used but I would like to generate a report that lists all ASM starts I can send an email to me and one other s/n.

    I am fairly new to dig in the tables and views under the control of cloud data base so any help would be appreciated.

    Hello

    You can check this:Cloud control 12 c: EM12c ASM storage report

    HTH

  • The use or condition in RTF model

    For the following code, the value appears correctly
    <? xdofx:If DR IS NULL then SEGMENT4 other end if parent_value? >

    However, when I try to include steps for 0, the following error message appears
    <? DR IS NULL or DR xdofx:If = 0 then SEGMENT4 other end if parent_value? >


    Caused by: oracle.xdo.parser.v2.XPathException: could not convert to number.
    at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
    at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
    at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)

    BI Publisher version is 10.1.3.4.2

    I forwarded the model u with condition update can you please check and let me know.

  • Why the feature multiple column indexes using index skip scan?

    Hi all

    I have just been hired by a new company and I explored its database infrastructure. Interestingly, I see several function based indexed column used for all the tables. I found it strange, but they said ' we use Axapta to connect Axapta with Oracle, function index according to should be used to improve performance. Therefore, our DBAs create several indexes of feature based for each table in the database. "Unfortunately, I can not judge their business logic.

    My question is, I just created similar to my local database tables in order to understand the behavior of the function index according to several columns. In order to create indexes of based function (substr and nls_lower), I have to declare the columns as varchars2. Because in my business our DBAs had created a number of columns as a varchar2 data type. I created two excatly same table for my experience. I create miltiple function according to index on the my_first table, and then I create several normal index on the my_sec table. The interesting thing is, index skip scan cannot be performed on more than one basic function index (table my_first). However, it can be performed to normal several index on my_sec table. I hope that I have to express myself clearly.

    Note: I also ask the logic of the rule function based index, they said when they index a column they don't ((column length) * 2 + 1) formula. For example, I want to create indexes on the zip code column, column data type VARCHAR2 (3), so I have to use 3 * 2 + 1 = 7, (substr (nls_lower (areacode), 1, 7). substr (nls_lower ()) notation is used nested for any function function index. I know that these things are very illogical, but they told me, they use this type of implementation for Axapta.

    Anyway, in this thread, my question is reletad to function function with index index skip scan, not logical bussiness, because I can not change the business logic.

    Also, can you please give hints or clues for multiple function based indexes?

    Thanks for your help.


    SQL > create table my_first as select '201' codeZone, to_char (100 + rownum) account_num, dbms_random.st
    Ring name ('A', 10) from dual connect by level < = 5000;

    Table created.

    SQL > create table my_sec as select '201' codeZone, to_char (100 + rownum) account_num, dbms_random.st

    Ring name ('A', 10) from dual connect by level < = 5000;

    Table created.

    SQL > alter table my_first change account_num varchar2 (12);

    Modified table.


    SQL > alter table my_sec change account_num varchar2 (12);

    Modified table.

    SQL > alter table my_first change codeZone VARCHAR2 (3);

    Modified table.

    SQL > alter table my_sec change codeZone VARCHAR2 (3);

    Modified table.

    SQL > create index my_first_i on my_first (substr (nls_lower (areacode), 1, 7), substr (nls_lower (account_num), 1, 15));

    The index is created.

    SQL > create index my_sec_i on my_sec (area code, account_num);

    The index is created.

    SQL > analyze table my_first computing statistics for all columns indexed for all indexes.

    Parsed table.

    SQL > analyze table my_sec computing statistics for all columns indexed for all indexes.

    Parsed table.

    SQL > exec dbms_stats.gather_table_stats (USER, 'MY_FIRST');

    PL/SQL procedure successfully completed.

    SQL > exec dbms_stats.gather_table_stats (USER, 'MY_SEC');

    PL/SQL procedure successfully completed.

    SQL > my_first desc;
    Name                                      Null?    Type
    ----------------------------------------- -------- ----------------------------
    CODEZONE VARCHAR2 (3)
    ACCOUNT_NUM VARCHAR2 (12)
    NAME VARCHAR2 (4000)

    SQL > desc my_sec
    Name                                      Null?    Type
    ----------------------------------------- -------- ----------------------------
    CODEZONE VARCHAR2 (3)
    ACCOUNT_NUM VARCHAR2 (12)
    NAME VARCHAR2 (4000)

    SQL > select * from my_sec where account_num = '4000';


    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 1838048852

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). TI
    me |

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

    |   0 | SELECT STATEMENT |          |     1.    19.     3 (0) | 00
    : 00:01 |

    |   1.  TABLE ACCESS BY INDEX ROWID | MY_SEC |     1.    19.     3 (0) | 00
    : 00:01 |

    |*  2 |   INDEX SKIP SCAN | MY_SEC_I |     1.       |     2 (0) | 00
    : 00:01 |

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


    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2 - access ("ACCOUNT_NUM" = '4000')
    Filter ("ACCOUNT_NUM" = '4000')


    Statistics
    ----------------------------------------------------------
    1 recursive calls
    0 db block Gets
    Gets 7 compatible
    0 physical reads
    0 redo size
    543 bytes sent via SQL * Net to client
    384 bytes received via SQL * Net from client
    2 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed

    SQL > select * from my_first where substr (nls_lower (account_num), 1: 25) = '4000';


    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 1110109060

    ------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    ------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |          |     1.    20.     9 (12) | 00:00:01 |
    |*  1 |  TABLE ACCESS FULL | MY_FIRST |     1.    20.     9 (12) | 00:00:01 |
    ------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 Filter (SUBSTR (NLS_LOWER ("MY_FIRST". "" "" ACCOUNT_NUM")(, 1, 15) ="4000"
    AND SUBSTR (NLS_LOWER ("ACCOUNT_NUM"), 1, 25) = '4000')


    Statistics
    ----------------------------------------------------------
    15 recursive calls
    0 db block Gets
    Gets 26 consistent
    0 physical reads
    0 redo size
    543 bytes sent via SQL * Net to client
    384 bytes received via SQL * Net from client
    2 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed

    SQL > Select / * + INDEX_SS (MY_FIRST) * / * from my_first where substr (nls_lower (account_num), 1: 25) = '4000';


    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 2466066660

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU).
    Time |

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

    |   0 | SELECT STATEMENT |            |     1.    20.    17 (6) |
    00:00:01 |

    |*  1 |  TABLE ACCESS BY INDEX ROWID | MY_FIRST |     1.    20.    17 (6) |
    00:00:01 |

    |*  2 |   INDEX SCAN FULL | MY_FIRST_I |     1.       |    16 (7) |
    00:00:01 |

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


    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 - filter (SUBSTR (NLS_LOWER ("ACCOUNT_NUM"), 1, 25) = '4000')
    2 - access (SUBSTR (NLS_LOWER ("ACCOUNT_NUM"), 1, 15) = '4000')
    Filter (substr (NLS_LOWER ("ACCOUNT_NUM"), 1, 15) = '4000')


    Statistics
    ----------------------------------------------------------
    15 recursive calls
    0 db block Gets
    857 consistent gets
    0 physical reads
    0 redo size
    543 bytes sent via SQL * Net to client
    384 bytes received via SQL * Net from client
    2 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed

    Check MoS for a bug with the FBI and Skip Scan - it sounds like it could be a bug.

    On 11.2.0.4 with your sample code 10053 trace shows the optimizer whereas an index FULL scan to the point where she should consider an index SKIP scan for "unique table path".

    A person with 12.1.0.1 practice would like to run your test and see if it's fixed in this version.

    Concerning

    Jonathan Lewis

  • Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Hello

    2796614 wrote:

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Of course, it is possible.  According to what the text file looks like to, you can create an external table that treats the text file as if it were a table.  Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.

    You have problems whatever you wantt?  If so, your zip code and explain what the problem is.

    Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas.  In this case, also post a small sample of the text involved file.

    If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • Implement conditional read-only column in the set of two Tables

    Hello

    I would like to implement a mechanism of "read-only conditional" on a column in a table with two tables in total to be involved in this situation.

    I have a demo/proof of concept of the present and things work as expected in the tests I've done; However, I would like any input as to if there is a better way, etc.

    This is a far-fetched but demo that illustrates the main ingredients however. Oracle 10.2.0.4 version 64 bit on Windows Server 2008 Release 2 64-bit.

    -Table DDL and small sample data
    create table band(
      band_id   number primary key,
      band_name varchar2(20),
      status    varchar2(20)
    );
    
    create table band_member(
      band_id references band,
      member_name varchar2(20)
    );
    
    insert into band values(3, 'The Rutles', 'prefab4');
    insert into band values(4, 'The Beatles', 'established');
    commit;
    
    insert into band_member values(3, 'Ron Nasty');
    insert into band_member values(3, 'Dirk McQuickly');
    insert into band_member values(3, 'Stig O''Hara');
    insert into band_member values(3, 'Barrington Womble');
    commit;
    
    insert into band_member values(4, 'John Lennon');
    insert into band_member values(4, 'Paul McCartney');
    insert into band_member values(4, 'George Harrison');
    insert into band_member values(4, 'Ringo Starr');
    commit;
    -The rules relating to the conditional objective of read-only

    1 is not allowed to update band.band_name when band.status = 'prefab4'
    2 is not allowed to insert/update / deletion of lines of band_member when the parent a band.status row = 'prefab4'

    -The triggers used to implement the goal (current solution)
    create or replace trigger t1
    before update of band_name on band
    for each row
    when (old.status = 'prefab4' or new.status = 'prefab4')
    begin
      raise_application_error(-20010,
        'can not update band_name when status=''prefab4''');
    end;
    /
    
    create or replace trigger t2
    before insert or update or delete on band_member
    for each row
    declare
      l_status band.status%type;
      l_band_id band_member.band_id%type;
      cursor l_cursor (p_band_id number) is
      select status from band
      where band_id = p_band_id
      for update;
    begin
      if updating or inserting then
        l_band_id := :new.band_id;
      else
        l_band_id := :old.band_id;
      end if;
      open l_cursor(l_band_id);
      fetch l_cursor into l_status;
      close l_cursor;
      if l_status = 'prefab4' then
        raise_application_error(-20011,
          'can not update child when parent status=''prefab4''');
      end if;
    end;
    /
    -Quick example of test for each condition
    update band
    set    band_name = 'THE RUTLES'
    where  band_id = 3;
    
    update band
           *
    ERROR at line 1:
    ORA-20010: can not update band_name when status='prefab4'
    ORA-06512: at "DEMO.T1", line 2
    ORA-04088: error during execution of trigger 'DEMO.T1'
    
    
    update band_member
    set    member_name = 'RON NASTY'
    where  member_name = 'Ron Nasty';
    
    update band_member
           *
    ERROR at line 1:
    ORA-20011: can not update child when parent status='prefab4'
    ORA-06512: at "DEMO.T2", line 18
    ORA-04088: error during execution of trigger 'DEMO.T2'
    As I said, while my simple tests seem to show the correct results, there I was wondering if there could be a better way to implement such functionality.

    I tried to provide the information needed, but if I managed to omit something, please let me know.

    See you soon,.

    Chalfont

    Hi, Chalfont,

    user13146957 wrote:
    ...
    I'm went to the road to slider to add the clause "for update" to force the serialization on the line - i.e. the idea was to avoid the case where another session might want to update the State a moment after my extraction but before the rest of the finished code. Who is?

    No, not really. The trigger on tape prevents anyone else from ever change their status from 'prefab4' to something else (or vice versa).
    Even apart from this, you put some efforts to prevent something which will be allowed a fraction of a second later (or maybe the other way around). What is significant in that split second?

    I didn't think about other ideas rather than the approach of the trigger, but came up empty, somehow, to this day. I am open to resort to others and make some schema changes is not off the table either.

    FGA (Fine grain access), or his brothers and sisters more older VPD (virtual private database) can also do what you want, but instead of trigger an error, they ignore the illegal action. This can be an advantage or a disadvantage, depending on your needs.

    Another approach is for the owner of the table, not to grant INSERT, UPDATE or DELETE privileges to anyone: all DML must be made via a procedure (or procedures) belonging to the owner of the table, which grants EXECUTE privileges instead of other privileges.

  • How to load a multiple column table in the coherence of caches?

    How to load a multiple column table in the coherence of caches?
    I want to load a multi-column (about 20 columns) table in cache coherence. How to change the following code (spatially how to change the SQL SELECT statement)?
    Is the following select statement enough: Select the key, the value of EMPLOYEES ?
    public static void bulkLoad(NamedCache cache, Connection conn)
        {
        Statement s;
        ResultSet rs;
        
        try
            {
            s = conn.createStatement();
            rs = s.executeQuery("select key, value from table");
            while (rs.next())
                {
                Integer key   = new Integer(rs.getInt(1));
                String  value = rs.getString(2);
                cache.put(key, value);
                }
            ...
            }
        catch (SQLException e)
            {...}
        }

    First of all, you need a class to hold your 20 fields:

    public class Data {
    
        private String field1;
        private String field2;
        private String field3;
        private String field4;
        private String field5;
        private String field6;
        private String field7;
        private String field8;
        private String field9;
        private String field10;
        private String field11;
        private String field12;
        private String field13;
        private String field14;
        private String field15;
        private String field16;
        private String field17;
        private String field18;
        private String field19;
        private String field20;
    
        public Data() {
        }
    
        public String getField1() {
            return field1;
        }
    
        public void setField1(String field1) {
            this.field1 = field1;
        }
    
        public String getField2() {
            return field2;
        }
    
        public void setField2(String field2) {
            this.field2 = field2;
        }
    
        public String getField3() {
            return field3;
        }
    
        public void setField3(String field3) {
            this.field3 = field3;
        }
    
        public String getField4() {
            return field4;
        }
    
        public void setField4(String field4) {
            this.field4 = field4;
        }
    
        public String getField5() {
            return field5;
        }
    
        public void setField5(String field5) {
            this.field5 = field5;
        }
    
        public String getField6() {
            return field6;
        }
    
        public void setField6(String field6) {
            this.field6 = field6;
        }
    
        public String getField7() {
            return field7;
        }
    
        public void setField7(String field7) {
            this.field7 = field7;
        }
    
        public String getField8() {
            return field8;
        }
    
        public void setField8(String field8) {
            this.field8 = field8;
        }
    
        public String getField9() {
            return field9;
        }
    
        public void setField9(String field9) {
            this.field9 = field9;
        }
    
        public String getField10() {
            return field10;
        }
    
        public void setField10(String field10) {
            this.field10 = field10;
        }
    
        public String getField11() {
            return field11;
        }
    
        public void setField11(String field11) {
            this.field11 = field11;
        }
    
        public String getField12() {
            return field12;
        }
    
        public void setField12(String field12) {
            this.field12 = field12;
        }
    
        public String getField13() {
            return field13;
        }
    
        public void setField13(String field13) {
            this.field13 = field13;
        }
    
        public String getField14() {
            return field14;
        }
    
        public void setField14(String field14) {
            this.field14 = field14;
        }
    
        public String getField15() {
            return field15;
        }
    
        public void setField15(String field15) {
            this.field15 = field15;
        }
    
        public String getField16() {
            return field16;
        }
    
        public void setField16(String field16) {
            this.field16 = field16;
        }
    
        public String getField17() {
            return field17;
        }
    
        public void setField17(String field17) {
            this.field17 = field17;
        }
    
        public String getField18() {
            return field18;
        }
    
        public void setField18(String field18) {
            this.field18 = field18;
        }
    
        public String getField19() {
            return field19;
        }
    
        public void setField19(String field19) {
            this.field19 = field19;
        }
    
        public String getField20() {
            return field20;
        }
    
        public void setField20(String field20) {
            this.field20 = field20;
        }
    }
    

    Then you can use it to store data in you original code

    public static void bulkLoad(NamedCache cache, Connection conn)
        {
        Statement s;
        ResultSet rs;
    
        try
            {
            s = conn.createStatement();
            String sql = "select key, value, value2, " +
                    "value3, value4, value5, value6, " +
                    "value7, value8, value9, value10 " +
                    "value11, value12, value13, value14, " +
                    "value15, value16, value17, value18, " +
                    "value19, value120 from table";
    
            rs = s.executeQuery(sql);
            while (rs.next())
                {
                Integer key   = new Integer(rs.getInt(1));
                Data data = new Data();
                data.setField1(rs.getString(2));
                data.setField2(rs.getString(3));
                data.setField3(rs.getString(4));
                data.setField4(rs.getString(5));
                data.setField5(rs.getString(6));
                data.setField6(rs.getString(7));
                data.setField7(rs.getString(8));
                data.setField8(rs.getString(9));
                data.setField9(rs.getString(10));
                data.setField10(rs.getString(11));
                data.setField11(rs.getString(12));
                data.setField12(rs.getString(13));
                data.setField13(rs.getString(14));
                data.setField14(rs.getString(15));
                data.setField15(rs.getString(16));
                data.setField16(rs.getString(17));
                data.setField17(rs.getString(18));
                data.setField18(rs.getString(19));
                data.setField19(rs.getString(20));
                data.setField20(rs.getString(21));
                cache.put(key, data);
                }
            ...
            }
        catch (SQLException e)
            {...}
        }    
    

    Of course your data object would need the appropriate field names and you will have no channels for all types. It must also implement equals and hashCode and ideally PortableObject.

    JK

  • UPDATE multiple columns with conditional parameters

    I have a procedure that updates several columns of a table using the parameter of the procedure. Is it possible to have a update unique with the parameter SET conditional statement?
    CREATE TABLE TEMP
    (POL_NUM NUMBER,
    OED DATE,
    TERM NUMBER,
    TRANS_CD CHAR(2));
    
    INSERT INTO TEMP VALUES (1, '1 AUG 2009', 12, 'NB');
    INSERT INTO TEMP VALUES (2, '4 AUG 2009', 12, 'XL');
    INSERT INTO TEMP VALUES (3, '2 AUG 2009', 12, 'RN');
    COMMIT;
    
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM NUMBER,
      pOED IN DATE,
      pTERM IN NUMBER,
      pTRANS_CD CHAR2)
    AS
    BEGIN
      IF pOED IS NOT NULL THEN
        UPDATE TEMP SET OED = pOED WHERE POL_NUM = pPOL_NUM;
      END IF;
    
      IF pTERM IS NOT NULL THEN
        UPDATE TEMP SET TERM = pTERM WHERE POL_NUM = pPOL_NUM;
      END IF;
    
      IF pTRAN_CD IS NOT NULL THEN
        UPDATE TEMP SET TRANS_CD = pTRANS_CD WHERE POL_NUM = pPOL_NUM;
      END IF;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
         NULL;
    END;
    Is it possible to replace several IFs code to have only one UPDATE statement with the condition that update the column only if the parameter passed is not null? In the real world scenario, I have more than 3 columns and I do not want to write lots of IF blocks.

    Please help gurus!

    Published by: Kuul13 on September 18, 2009 13:26

    Hello

    Maybe this,.

    Create OR Replace Procedure TMP_PROC( pPOL_NUM  IN Number
                                        , pOED      IN Date
                                        , pTERM     IN Number
                                        , pTRANS_CD IN Varchar2 ) As
    Begin
       UPDATE TEMP
          SET OED      = NVL(POED     , OED )
            , TERM     = NVL(PTERM    , TERM )
            , TRANS_CD = NVL(PTRANS_CD, TRANS_CD )
        WHERE POL_NUM = PPOL_NUM;
       Commit;
    Exception
       When Others Then
          Null;
    End;
    

    Kind regards
    Christian Balz

  • Trying to create a Section to multiple columns with Sections of the single column before and after

    Is there a way to create a section break that is not default to a new page after I created columns on a page.  I created the columns and under them, I want to return to the normal formatting for the rest of the single page.  See picture attached.

    Any rejection of Pages v5 has a break of presentation which was present in the Pages ' 09 v4.3. This will allow you to transition to several columns and back to single column on the same page. In the v5 Pages, you can insert 3 text boxes and change the 3-column layout in the Middle text box. You use the toolbar item Insert to inject column breaks when you want to start a new list in the next column. I'll show this screenshot below.

    You can fake your layout in Pages v5 using 3 text boxes and setting 3 columns in the Central text area. Better to show the mode of provision for this and in a text box, the column outlines are not displayed. After each column list, you then choose column break the Insert point toolbar menu to move to the next column, add a list, repeat. Each column will expand downwards. Click on the following to enlarge.

    Pages ' 09 v4.3 using layout breaks Pages using 3 text boxes V5.6.1                                                      

      

Maybe you are looking for