Wrong result in query.

Hi, SAP gurus,
i am creating a aging query on Service Call, to return Calls pending between specified days..
to get days, i used
where  datediff(day, oscl1.createdate,getdate()) >= 0 and 100
below executed query is working fine...
Select
oscl1.callid,
oscl1.custmrname,
oscl1.itemcode,
oscl1.itemname,
oscs.name,
datediff(day,oscl1.createdate,getdate()) 'Pending (Days)'
from oscl oscl1
inner join oscs on
oscs.statusid = oscl1.status
where datediff(day,oscl1.createdate,getdate()) between  0 and 100
and oscl1.status!=-1
now i am trying to accept days from user
for that i wrote
where datediff(day,oscl1.createdate,getdate()) between  [%0] and [%1]
but the above clause is not getting executed...
below is my code
--query not getting executed.
Select
oscl1.callid,
oscl1.custmrname,
oscl1.itemcode,
oscl1.itemname,
oscs.name,
datediff(day,oscl1.createdate,getdate()) 'Pending (Days)'
from oscl oscl1
inner join oscs on
oscs.statusid = oscl1.status
where datediff(day,oscl1.createdate,getdate()) between  [%0] and [%1] '-- not getting execute this clause.
--where oscl1.createdate  between  [%0] and [%1] '-- this clause is working fine.
and oscl1.status!=-1
but in where clause if i give condition like
where oscl1.createdate  between  [%0] and [%1]
the above clause is working fine,
does any one know where i am doing wrong in this query..?
i appreciate your help..
Thanks and Regards,
kaviprashu

Hi,
Thanks Jitin,
but i am trying to accept values in days from user...
for that i wrote :
where datediff(day,oscl1.createdate,getdate()) between  0 and 30  '-- return Calls pending between 0 and 30 days
the above clause is working fine...
but if i try to get value from user and execute clause as below, is not getting executed!
where datediff(day,oscl1.createdate,getdate()) between  [%0] and [%1]  '-- not getting executed ]
but if i skip datediff() function, and execute, its working fine...
where oscl1.createdate between  [%0] and [%1]
i have doubt, does Query Generator consider ' [%0] ' as date field..?
how do i accept days from user?
i appreciate your help..
Thanks and Regards,
kaviprashu

Similar Messages

  • Wrong result for query with like and %

    I have a strange problem with query with like and %.
    When I run this script:
    ALTER SESSION SET NLS_SORT = 'BINARY_CI';
    ALTER SESSION SET NLS_COMP = 'LINGUISTIC';
    -- SELECT * FROM NLS_SESSION_PARAMETERS;
    -- drop table test1;
    CREATE TABLE TEST1(K1 NVARCHAR2(80));
    INSERT INTO TEST1 VALUES ('gsdk');
    INSERT INTO TEST1 VALUES ('ąxyz');
    INSERT INTO TEST1 VALUES ('ŁFa');
    INSERT INTO TEST1 VALUES ('ła');
    INSERT INTO TEST1 VALUES ('Śab');
    INSERT INTO TEST1 VALUES ('Śrrrb');
    commit;
    select * from TEST1 where k1 like N'Ł%';
    I get this:
    K1
    ŁFa
    ła
    Śab <- WRONG
    Śrrrb <- WRONG
    4 rows selected
    When i change datatype to varchar2 this code work correct.
    Is this a bug or what ?
    The execution plan:
    PLAN_TABLE_OUTPUT
    SQL_ID d3d64aupz4bb5, child number 2
    select * from TEST1 where k1 like N'Ł%'
    Plan hash value: 4122059633
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | | | 2 (100)| |
    |* 1 | TABLE ACCESS FULL| TEST1 | 1 | 82 | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter((NLSSORT("K1",'nls_sort=''BINARY_CI''')>=HEXTORAW('014200'
    ) AND NLSSORT("K1",'nls_sort=''BINARY_CI''')<HEXTORAW('01610100') ))
    Note
    - dynamic sampling used for this statement (level=2)

    DATABASE NLS CONFIGURATION:
    NLS_CHARACTERSET AL32UTF8
    NLS_NCHAR_CHARACTERSET     AL16UTF16
    NLS_COMP     BINARY
    NLS_SORT     BINARY
    Oracle version 11.2.0.2.0

  • Wrong result of query

    I have these two queries which differ each other only for the order of conditions (...and...and...and), and give different results as below.
    I think this is a bug and I'm afraid this kind of mistake can affect random any similar SQL query on which I'm not aware.
    Can anyone give me a logical explanation?
    SQL*Plus: Release 9.2.0.1.0 - Production on Wed Aug 30 14:26:38 2006
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    SQL> create table styles (code varchar2(10),spec varchar2(4));
    Table created.
    SQL> insert into styles values ('1','SPSK');
    1 row created.
    SQL> insert into styles values ('2',null);
    1 row created.
    SQL> select distinct spec from styles s where
    '1' is null and
    ('SPSK' IS NULL OR
    ('SPSK'='S' AND S.SPEC IS NOT NULL)
    OR ('SPSK'='N' AND S.SPEC IS NULL)
    OR S.SPEC='SPSK' )
    AND NVL('CONTEX','Undefined') IN
    (' All (with and without maker)',' Only without maker','Undefined' );
    no rows selected
    SQL> select distinct spec from styles s where
    ('SPSK' IS NULL OR
    ('SPSK'='S' AND S.SPEC IS NOT NULL)
    OR ('SPSK'='N' AND S.SPEC IS NULL)
    OR S.SPEC='SPSK' )
    AND NVL('CONTEX','Undefined') IN
    (' All (with and without maker)',' Only without maker','Undefined' )
    and '1' is null;
    SPEC
    SPSK
    P.S.: The same thing happens on the following release for Windows NT
    SQL*Plus: Release 3.3.2.0.2 - Production on Wed Aug 30 14:18:25 2006
    Copyright (c) Oracle Corporation 1979, 1994. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production

    Works for me on 9.2.0.4:
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
    SQL> select distinct spec
      2  from   styles s
      3  where  '1' is null
      4  and    ('SPSK' IS NULL
      5          OR ('SPSK'='S' AND S.SPEC IS NOT NULL)
      6          OR ('SPSK'='N' AND S.SPEC IS NULL)
      7          OR S.SPEC='SPSK'
      8         )
      9  AND    NVL('CONTEX','Undefined') IN
    10               (' All (with and without maker)',' Only without maker','Undefined' );
    no rows selected
    SQL> select distinct spec
      2  from   styles s
      3  where  ('SPSK' IS NULL
      4          OR ('SPSK'='S' AND S.SPEC IS NOT NULL)
      5          OR ('SPSK'='N' AND S.SPEC IS NULL)
      6          OR S.SPEC='SPSK'
      7         )
      8  AND    NVL('CONTEX','Undefined') IN
      9               (' All (with and without maker)',' Only without maker','Undefined' )
    10  and   '1' is null;
    no rows selectedYou're still on the initial release of 9.2. Maybe time to apply a patch or two?

  • Timestamp - wrong results during clock change

    When I run for example:
    SELECT TO_TIMESTAMP('28.03.2010 02:00:00','DD.MM.YYYY HH24:MI:SS') FROM dual
    on worksheet, I receive two different results:
    Script Output:
    28.03.2010 02:00:00
    Query Result:
    28.03.2010 03:00:00
    What is the reason for the wrong result in "Query Result"?
    Rainer

    Things that might influence, but could be different for you:
    - WinXP SP3 Catalonia/Spain locale (adjusts to summer-time)
    - AddVMOption -Duser.language=en
    - AddVMOption -Doracle.jdbc.mapDateToTimestamp=false
    - sqldev NLS Language/Territory: American/America
    Hope that helps,
    K.

  • Query giving wrong results

    Below is the query thats giving me wrong results ...can anyone help me figure where i am going wrong :(
    SQL> select count(*) from t where source='LP1.1';
      COUNT(*)
            69
    SQL> select count(*) from tblspring where line_a='LP1.1';
      COUNT(*)
           233now when i join these two table ...the total counts exceeds the expected records that i want
    SQL> select count(*) from t , tblspring where t.source=tblspring.line_a and t.source='LP1.1';
      COUNT(*)
         16077

    the thing is i want to filter only those records from table t where the column named  - source is equal to the column named line_a from table tblspring from the query in table t i get 69 records ....
    now when i match the it table tblspring with the condition
    i want the number of records should be less than or equal to 69 but not more than 69
    Edited by: Suhail Faraaz on Mar 5, 2011 7:31 AM

  • Query giving wrong result

    Hi
    Could anybody tell me why this query is giving the wrong result? The column 'Spend for Selected Period' is showing as far too much (ie exactly 11 times too much!!!) when totalling the 37 invoices involved
    SELECT T0.[CardCode], T0.[CardName],T0.[MailCity] AS 'Town', T2.[SlpName] AS 'Rep',
    SUM(T1.DocTotal - T1.VatSum)  AS 'Spend for Selected Period', MAX(T3.CreateDate) AS 'Last Visit Date'
    FROM OCRD T0  left JOIN OINV T1 ON T0.CardCode = T1.CardCode LEFT JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode LEFT JOIN OSCL T3 ON T0.CardCode = T3.Customer
    where  T0.[CardCode] = 'wyk027/34' AND T1.DocDate BETWEEN '20090101' AND '20091231'
    GROUP BY T0.[CardCode], T0.[CardName],T0.[MailCity], T2.[SlpName]
    Thanks
    Steve

    Hi ,
    It seems like it is duplicated by the number of service calls.
    Try this one:
    SELECT T0.CardCode, T0.CardName,T0.MailCity AS 'Town', T2.SlpName AS 'Rep',
    SUM(T1.DocTotal - T1.VatSum) AS 'Spend for Selected Period', (select MAX(T3.CreateDate) from OSCL T3 where T0.CardCode = T3.Customer) AS 'Last Visit Date'
    FROM OCRD T0 inner JOIN OINV T1 ON T0.CardCode = T1.CardCode inner JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
    where T0.CardCode = '10001' AND T1.DocDate BETWEEN '20090101' AND '20091231'
    GROUP BY T0.CardCode, T0.CardName,T0.MailCity, T2.SlpName
    Best regards,
    Maya

  • Simple query with like return wrong result

    Hi,
    I run simple query with like.
    If I use parameter I get wrong results.
    If I use query without parameter results are ok.
    My script:
    ALTER SESSION SET NLS_SORT=BINARY_CI;
    ALTER SESSION SET NLS_COMP=LINGUISTIC;
    -- drop table abcd;
    create table abcd (col1 varchar2(10));
    INSERT INTO ABCD VALUES ('122222');
    insert into abcd values ('111222');
    SELECT * FROM ABCD WHERE COL1 LIKE :1; -- wrong result with value 12%
    COL1
    122222
    *111222*
    select * from abcd where col1 like '12%'; -- result ok
    COL1
    122222
    I use Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    and query run in Oracle SQL Developer 3.1.07.

    Hi,
    welcome to the forum.
    When you put some code please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    You should specify exactly how you run your code.
    If I run this statement in SQL Plus:SQL> ALTER SESSION SET NLS_SORT=BINARY_CI;
    Session altered.
    SQL> ALTER SESSION SET NLS_COMP=LINGUISTIC;
    Session altered.
    SQL>
    SQL> -- drop table abcd;
    SQL> create table abcd (col1 varchar2(10));
    Table created.
    SQL>
    SQL> INSERT INTO ABCD VALUES ('122222');
    1 row created.
    SQL> insert into abcd values ('111222');
    1 row created.
    SQL>
    SQL> SELECT * FROM ABCD WHERE COL1 LIKE :1;
    SP2-0552: Bind variable "1" not declared.
    SQL>
    I got this error. So I wonder how you set value 12%
    Please specify exactly how you run your test as we cannot reproduce your problem.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Query returning wrong results - Help required.

    Hi All,
    I am having a query in which I have 10 records, 5 with stop time 1 and 5 with stop time 2.
    I have a scenario in which, I need to calculate the maximum,minimum for the records
    with stop time 1 and 2.
    What I did is, I selected all the 10 records using for loop. Within the loop
    I am trying to find the maximum and minimum. It is giving me wrong results.
    Please help me. My code is follows
    declare
         v_p1_min_stop_tm     number;
         v_p1_max_stop_tm     number;
         v_p2_min_stop_tm     number;
         v_p2_max_stop_tm     number;
    begin
         for i in(
              select
                   stop_tm
              from
                   sample_stop
              where
                   map_nbr = 16645 and
                   stop_dt = '05-sep-08'
         )loop
              if i.stop_tm = 1 then
                   select
                        min(i.stop_tm),
                        max(i.stop_tm)
                   into
                        v_p1_min_stop_tm,
                        v_p1_max_stop_tm
                   from
                        dual;
              elsif i.stop_tm = 2 then
                   select
                        min(i.stop_tm),
                        max(i.stop_tm)
                   into
                        v_p2_min_stop_tm,
                        v_p2_max_stop_tm
                   from
                        dual;
              end if;
         end loop;
         dbms_output.put_line('minimum p1 stop time : '|| v_p1_min_stop_tm);
         dbms_output.put_line('maximum p1 stop time : '|| v_p1_max_stop_tm);
         dbms_output.put_line('minimum p2 stop time : '|| v_p2_min_stop_tm);
         dbms_output.put_line('maximum p2 stop time : '|| v_p2_max_stop_tm);
    end;
    My o/p is :
    Minimum P1 stop time : 523
    Maximum P1 stop time : 523
    Minimum P2 stop time : 719
    Maximum P2 stop time : 719
    Here how can I make the data as two sets, one set with stop time 1 and
    other with stop time 2.
    Regards
    Raghu

    If the data type of stop_tm is varchar then try following
    declare
         v_p1_min_stop_tm number;
         v_p1_max_stop_tm number;
         v_p2_min_stop_tm number;
         v_p2_max_stop_tm number;
    begin
         for i in(select  stop_tm  from  sample_stop
              where
                   map_nbr = 16645 and
                   stop_dt = '05-sep-08'
              )loop
         if i.stop_tm = 1 then
              select min(to_number(i.stop_tm)), max(to_number(i.stop_tm))
                   into v_p1_min_stop_tm,v_p1_max_stop_tm
              from
                   dual;
         elsif i.stop_tm = 2 then
              select
                   min(to_number(i.stop_tm)),     max(to_number(i.stop_tm))
                   into
                   v_p2_min_stop_tm,v_p2_max_stop_tm
              from
                   dual;
         end if;
    end loop;
    dbms_output.put_line('minimum p1 stop time : '|| v_p1_min_stop_tm);
    dbms_output.put_line('maximum p1 stop time : '|| v_p1_max_stop_tm);
    dbms_output.put_line('minimum p2 stop time : '|| v_p2_min_stop_tm);
    dbms_output.put_line('maximum p2 stop time : '|| v_p2_max_stop_tm);
    end;
    / Regards
    Singh

  • Wrong results after upgrading 10g database to 11.2.0.2.6

    Hi,
    Do anyone know, why the following query results are different?
    Not Working query:
    sql1:
    select col1 from tab1
    where col1 = (select '123' from dual)
    Working query:
    sql2:
    select col1 from tab1
    where col1 = '123';
    Both the sql1 and sql2 are returning same reseults in 10g database , but not in 11g.

    Pl post OS details along with sample outputs and explain plans from the the sql1 statement from the two databases. These MOS Docs may help also
    Things to Consider Before Upgrading to 11.2.0.2 to Avoid Poor Performance or Wrong Results [ID 1320966.1]
    Wrong Results on 11.2.0.2 with Function-Based Index and OR Expansion [ID 1264550.1]
    Wrong Results/No Rows for Sql Involving Functions in 11.2.0.2. [ID 1380679.1]
    HTH
    Srini

  • NOT IN operator giving the wrong results

    DB version:10gR2
    Why is NOT IN giving the wrong results. Isn't NOT EXISTS operator a flawless alternative to NOT IN?
    create table my_table1 (col1 number);
    insert into my_table1 values (1);
    insert into my_table1 values (2);
    commit;
    create table my_table2 ( col1 number);
    insert into my_table2 values (1);
    commit;
    select * from my_Table1;
           COL1
              1
              2
    select * from my_table2;
           COL2
              1
      --correct result
      SELECT * FROM my_table1 t1 WHERE NOT EXISTS
    (SELECT * FROM my_table2 t2 WHERE t1.col1 = t2.col1)
           COL1
              2
    ---correct result using IN
    SELECT * FROM my_table1 t1 where col1 not in (select col1 FROM my_table2 t2);
           COL1
              2
    Inserting a NULL to my_Table2
    Now the query using NOT IN is returning wrong results.
    insert into my_table2 values (null);
    commit;
    SELECT * FROM my_table1 t1 where col1 not in (select col1 FROM my_table2 t2);
    no rows selected
    Query using NOT EXISTS is still giving the right results.
    SELECT * FROM my_table1 t1 WHERE NOT EXISTS
       (SELECT * FROM my_table2 t2 WHERE t1.col1 = t2.col1);
           COL1
              2

    ScottsTiger wrote:
    can i use NOT EXISTS(with a proper Co-related subquery) as a safe alternative to NOT IN?Depends on your data and what you need to achieve.
    Personally I avoid using NOT EXISTS or NOT IN if I can really help it.
    My preferred method is to outer join the tables together and then remove any resultant rows where a value exists and I didn't want one. ;)

  • Wrong results for context search on empty element tags

    I'm using Oracle DBMS 11.1 and 11.2 and created a context index on an XML column (section group: PATH_SECTION_GROUP).
    When entering a query like
    SELECT count(*) FROM my_table t WHERE contains (t.co_xml,'hasPath(/tag1/tag2)') > 0
    I get wrong results if tag2 is an empty element tag (<tag2/>) that appears somewhere within the
    XML instance, but NOT directly under tag1.
    E.g., the following XML instance is found (but shouldn't!):
    <a>
    <tag1>bla<tag3>bla</tag3></tag1>
    <tag4>bla<tag2/></tag4>
    </a>
    This seems to happen only for empty element tags. Is this a known bug and does anybody know a workaround?
    Thanks in advance for your help!
    Roman

    I am unable to reproduce the problem. Can you provide a copy and paste of an actual run, including create table, insert data, create index, and select, as I have done below?
    SCOTT@orcl_11g> select * from v$version
      2  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE     11.1.0.6.0     Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    SCOTT@orcl_11g> create table my_table
      2    (co_xml     xmltype)
      3  /
    Table created.
    SCOTT@orcl_11g> insert into my_table values (
      2  xmltype ('<?xml version="1.0"?>
      3  <tag5>
      4    <tag1>bla<tag3>bla</tag3></tag1>
      5    <tag4>bla<tag2/></tag4>
      6  </tag5>'))
      7  /
    1 row created.
    SCOTT@orcl_11g> create index my_idx
      2  on my_table (co_xml)
      3  indextype is ctxsys.context
      4  parameters ('section group ctxsys.path_section_group')
      5  /
    Index created.
    SCOTT@orcl_11g> SELECT count(*)
      2  FROM   my_table t
      3  WHERE  contains (t.co_xml, 'hasPath (//tag1/tag2)') > 0
      4  /
      COUNT(*)
             0
    SCOTT@orcl_11g> SELECT count(*)
      2  FROM   my_table t
      3  WHERE  contains (t.co_xml, 'hasPath (//tag1/tag3)') > 0
      4  /
      COUNT(*)
             1
    SCOTT@orcl_11g>

  • Wrong result in Web Intelligence Report

    Post Author: shriram81
    CA Forum: WebIntelligence Reporting
    When I run a query for web inteeligence documnet I receive a wrong result. But when I run the same SQL query in SQL analyzer of MS SQL server I get correct result.
    e.g. I get the same value of measure object against different dimension in web inteeligence report but I get correct values of measure when I run the query in query analyzer on SQl server
    Pl guide me to get correct result in Webi

    Post Author: GregPye
    CA Forum: WebIntelligence Reporting
    Are you copying and pasting the query from WebI into SQL Server? Seems a bit odd, as the SQL should be sent to SQL Server to run...
    I would check the report level settings, such as filters, or what have you... also check that there aren't more than one SQL query being run in WebI that you haven't noticed...
    Cheers

  • Bug 2679062 - Wrong results possible from multi-column INLIST - though stat

    Hi,
    The following test case is supplied in the metalink in bug no. 2871341, the base bug for this bug is 2679062.
    REPRODUCIBILITY:
    Reproduces constantly with simple test case below:
    TEST CASE:
    DROP TABLE A1
    CREATE TABLE A1 (X1 VARCHAR2(10), X2 VARCHAR2(10))
    REM *********** Create the second table: ***************
    DROP TABLE A2
    CREATE TABLE A2 (X1 VARCHAR2(10), X2 VARCHAR2(10))
    INSERT INTO A1 VALUES ('1','2');
    INSERT INTO A2 VALUES ('3','4');
    COMMIT;
    CREATE INDEX A1_X1 ON A1(X1 );
    CREATE INDEX A1_X2 ON A1(X2);
    CREATE INDEX A2_X1 ON A2(X1);
    CREATE INDEX A2_X2 ON A2(X2);
    CREATE OR REPLACE VIEW A_ALL AS SELECT * FROM A1 UNION ALL SELECT * FROM A2;
    ANALYZE TABLE A1 COMPUTE STATISTICS;
    ANALYZE TABLE A2 COMPUTE STATISTICS;
    SELECT * FROM A_ALL;
    SELECT * FROM A_ALL WHERE (X1='1' AND X2='2') ;
    SELECT * FROM A_ALL WHERE ((X1='1' AND X2='2') OR (X1='3' AND X2='4'));
    The 2nd query returns answer while the second is not !
    The following is published in the 9.2.0.4 fixed bug list:
    " 9204 - 2679062 - Wrong results possible from multi-column INLIST "
    I have installed 9.2.0.4 patch set on a win 2000 machine Oracle and saw that the above case is actually solved but our application which has a very similar case doesn't.
    After investigating I found the following test case that fails, it reproduces only when you have index on all columns (covering index):
    drop table t1_1;
    drop table t1_2;
    create table t1_1(c1 number, c2 number, c3 number);
    create table t1_2(c1 number, c2 number, c3 number);
    create index t1_1_ix on t1_1(c1, c2, c3);
    create index t1_2_ix on t1_2(c1, c2, c3);
    create or replace view t1 as select * from t1_1 union all select * from t1_2;
    insert into t1_1 values(1, 2, 100);
    insert into t1_2 values(1, 2, 200);
    commit;
    analyze table t1_1 compute statistics;
    analyze table t1_2 compute statistics;
    prompt
    prompt #######################################
    prompt try 1 - works fine
    prompt #######################################
    prompt
    select * from t1
    where
    (c1=1)
    and
    ( (c2=2) and (c3=100)
    prompt
    prompt #######################################
    prompt try 2 - works fine
    prompt #######################################
    prompt
    select * from t1
    where
    (c1=1)
    and
    (c2=2) and (c3=200)
    prompt
    prompt #######################################
    prompt try 3 - try 1 OR try 2 does not work !
    prompt #######################################
    prompt
    select * from t1
    where
    (c1=1)
    and
    ( ( (c2=2) and (c3=100) )
    or
    ( (c2=2) and (c3=200) )
    opened a TAR and wanted to share with you.
    Tal Olier ([email protected]).

    Hi,
    The following test case is supplied in the metalink in bug no. 2871341, the base bug for this bug is 2679062.
    REPRODUCIBILITY:
    Reproduces constantly with simple test case below:
    TEST CASE:
    DROP TABLE A1
    CREATE TABLE A1 (X1 VARCHAR2(10), X2 VARCHAR2(10))
    REM *********** Create the second table: ***************
    DROP TABLE A2
    CREATE TABLE A2 (X1 VARCHAR2(10), X2 VARCHAR2(10))
    INSERT INTO A1 VALUES ('1','2');
    INSERT INTO A2 VALUES ('3','4');
    COMMIT;
    CREATE INDEX A1_X1 ON A1(X1 );
    CREATE INDEX A1_X2 ON A1(X2);
    CREATE INDEX A2_X1 ON A2(X1);
    CREATE INDEX A2_X2 ON A2(X2);
    CREATE OR REPLACE VIEW A_ALL AS SELECT * FROM A1 UNION ALL SELECT * FROM A2;
    ANALYZE TABLE A1 COMPUTE STATISTICS;
    ANALYZE TABLE A2 COMPUTE STATISTICS;
    SELECT * FROM A_ALL;
    SELECT * FROM A_ALL WHERE (X1='1' AND X2='2') ;
    SELECT * FROM A_ALL WHERE ((X1='1' AND X2='2') OR (X1='3' AND X2='4'));
    The 2nd query returns answer while the second is not !
    The following is published in the 9.2.0.4 fixed bug list:
    " 9204 - 2679062 - Wrong results possible from multi-column INLIST "
    I have installed 9.2.0.4 patch set on a win 2000 machine Oracle and saw that the above case is actually solved but our application which has a very similar case doesn't.
    After investigating I found the following test case that fails, it reproduces only when you have index on all columns (covering index):
    drop table t1_1;
    drop table t1_2;
    create table t1_1(c1 number, c2 number, c3 number);
    create table t1_2(c1 number, c2 number, c3 number);
    create index t1_1_ix on t1_1(c1, c2, c3);
    create index t1_2_ix on t1_2(c1, c2, c3);
    create or replace view t1 as select * from t1_1 union all select * from t1_2;
    insert into t1_1 values(1, 2, 100);
    insert into t1_2 values(1, 2, 200);
    commit;
    analyze table t1_1 compute statistics;
    analyze table t1_2 compute statistics;
    prompt
    prompt #######################################
    prompt try 1 - works fine
    prompt #######################################
    prompt
    select * from t1
    where
    (c1=1)
    and
    ( (c2=2) and (c3=100)
    prompt
    prompt #######################################
    prompt try 2 - works fine
    prompt #######################################
    prompt
    select * from t1
    where
    (c1=1)
    and
    (c2=2) and (c3=200)
    prompt
    prompt #######################################
    prompt try 3 - try 1 OR try 2 does not work !
    prompt #######################################
    prompt
    select * from t1
    where
    (c1=1)
    and
    ( ( (c2=2) and (c3=100) )
    or
    ( (c2=2) and (c3=200) )
    opened a TAR and wanted to share with you.
    Tal Olier ([email protected]).

  • Please Help Urgent:Fast Search returning wrong result sets

    Hi All,
    We are facing below issue with fast search.
    Currently in My project  when  we are searching  for a phrase it is returning wrong result sets.
    For example if we search for “Endura”, It is returning documents related to
    Endura  as well as Centura.
    But the expected results are only Endura documents.
    When we look in to the documents we didn’t find the search term (“Endura” ) either inside document content or in its meta data.
    In order to resolve the issue we tried the below steps
    1-     
    We manually edited and saved the document, to ensure the appropriate Guid association to metadata.
    2-     
    Index reset
    3-     
    Full crawl
    But no luck  so far.
    Please help.Thanks in advance.
    Regards
    Subrat

    Subrat,
    This may be related to spellchecking or may be synonym. Spellcheck is based on indexed terms.
    The best test would be to run the queries from qrserver (13280) and then look at the spellcheck query transformations. If spellchecking is not doing it, then you must have a synonym setup .Check your keyword/synonyms from the SharePoint side. 

  • Select for update gives wrong results. Is it a bug?

    Hi,
    Select for update gives wrong results. Is it a bug?
    CREATE TABLE TaxIds
    TaxId NUMBER(6) NOT NULL,
    LocationId NUMBER(3) NOT NULL,
    Status NUMBER(1)
    PARTITION BY LIST (LocationId)
    PARTITION P111 VALUES (111),
    PARTITION P222 VALUES (222),
    PARTITION P333 VALUES (333)
    ALTER TABLE TaxIds ADD ( CONSTRAINT PK_TaxIds PRIMARY KEY (TaxId));
    CREATE INDEX NI_TaxIdsStatus ON TaxIds ( NVL(Status,0) ) LOCAL;
    Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (100101, 111, NULL);
    Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (100102, 111, NULL);
    Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (100103, 111, NULL);
    Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (100104, 111, NULL);
    Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (200101, 222, NULL);
    Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (200102, 222, NULL);
    Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (200103, 222, NULL);
    --Session_1 return TAXID=100101
    select TAXID from TAXIDS where LOCATIONID=111 and NVL(STATUS,0)=0 AND rownum=1 for update
    --Session_2 waits commit
    select TAXID from TAXIDS where LOCATIONID=111 and NVL(STATUS,0)=0 AND rownum=1 for update
    --Session_1
    update TAXIDS set STATUS=1 Where TaxId=100101;
    commit;
    --Session_2 return 100101 opps!?
    --Session_1 return TAXID=100102
    select TAXID, STATUS from TAXIDS where LOCATIONID=111 and NVL(STATUS,0)=0 AND rownum=1 for update
    --Session_2 waits commit
    select TAXID, STATUS from TAXIDS where LOCATIONID=111 and NVL(STATUS,0)=0 AND rownum=1 for update
    --Session_1
    update TAXIDS set STATUS=1 Where TaxId=100102;
    commit;
    --Session_2 return 100103                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    This is a bug. Got to be a bug.
    This should be nothing to do with indeterminate results from ROWNUM, and nothing to do with read consistency at the point of statement start time in session2., surely.
    Session 2 should never return 100101 once the lock from session 1 is released.
    The SELECT FOR UPDATE should restart and 100101 should not be selected as it does not meet the criteria of the select.
    A statement restart should ensure this.
    A number of demos highlight this.
    Firstly, recall the original observation in the original test case.
    Setup
    SQL> DROP TABLE taxids;
    Table dropped.
    SQL> 
    SQL> CREATE TABLE TaxIds
      2  (TaxId NUMBER(6) NOT NULL,
      3   LocationId NUMBER(3) NOT NULL,
      4   Status NUMBER(1))
      5  PARTITION BY LIST (LocationId)
      6  (PARTITION P111 VALUES (111),
      7   PARTITION P222 VALUES (222),
      8   PARTITION P333 VALUES (333));
    Table created.
    SQL>
    SQL> ALTER TABLE TaxIds ADD ( CONSTRAINT PK_TaxIds PRIMARY KEY (TaxId));
    Table altered.
    SQL>
    SQL> CREATE INDEX NI_TaxIdsStatus ON TaxIds ( NVL(Status,0) ) LOCAL;
    Index created.
    SQL>
    SQL>
    SQL> Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (100101, 111, NULL);
    1 row created.
    SQL> Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (100102, 111, NULL);
    1 row created.
    SQL> Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (100103, 111, NULL);
    1 row created.
    SQL> Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (100104, 111, NULL);
    1 row created.
    SQL> Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (200101, 222, NULL);
    1 row created.
    SQL> Insert into TAXIDS (TAXID, LOCATIONID, STATUS) Values (200102, 222, NULL);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> Original observation:
    Session1>SELECT taxid
      2  FROM   taxids
      3  WHERE  locationid    = 111
      4  AND    NVL(STATUS,0) = 0
      5  AND    ROWNUM        = 1
      6  FOR UPDATE;
         TAXID
        100101
    Session1>
    --> Session 2 with same statement hangs until
    Session1>BEGIN
      2   UPDATE taxids SET status=1 WHERE taxid=100101;
      3   COMMIT;
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    Session1>
    --> At which point, Session 2 returns
    Session2>SELECT taxid
      2  FROM   taxids
      3  WHERE  locationid    = 111
      4  AND    NVL(STATUS,0) = 0
      5  AND    ROWNUM        = 1
      6  FOR UPDATE;
         TAXID
        100101
    Session2>There's no way that session 2 should have returned 100101. That is the point of FOR UPDATE. It completely reintroduces the lost UPDATE scenario.
    Secondly, what happens if we drop the index.
    Let's reset the data and drop the index:
    Session1>UPDATE taxids SET status=0 where taxid=100101;
    1 row updated.
    Session1>commit;
    Commit complete.
    Session1>drop index NI_TaxIdsStatus;
    Index dropped.
    Session1>Then try again:
    Session1>SELECT taxid
      2  FROM   taxids
      3  WHERE  locationid    = 111
      4  AND    NVL(STATUS,0) = 0
      5  AND    ROWNUM        = 1
      6  FOR UPDATE;
         TAXID
        100101
    Session1>
    --> Session 2 hangs again until
    Session1>BEGIN
      2   UPDATE taxids SET status=1 WHERE taxid=100101;
      3   COMMIT;
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    Session1>
    --> At which point in session 2:
    Session2>SELECT taxid
      2  FROM   taxids
      3  WHERE  locationid    = 111
      4  AND    NVL(STATUS,0) = 0
      5  AND    ROWNUM        = 1
      6  FOR UPDATE;
         TAXID
        100102
    Session2>Proves nothing, Non-deterministic ROWNUM you say.
    Then let's reset, recreate the index and explicity ask then for row 100101.
    It should give the same result as the ROWNUM query without any doubts over the ROWNUM, etc.
    If the original behaviour was correct, session 2 should also be able to get 100101:
    Session1>SELECT taxid
      2  FROM   taxids
      3  WHERE  locationid    = 111
      4  AND    NVL(STATUS,0) = 0
      5  AND    taxid         = 100101
      6  FOR UPDATE;
         TAXID
        100101
    Session1>
    --> same statement hangs in session 2 until
    Session1>BEGIN
      2   UPDATE taxids SET status=1 WHERE taxid=100101;
      3   COMMIT;
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    Session1>
    --> so session 2 stops being blocked and:
    Session2>SELECT taxid
      2  FROM   taxids
      3  WHERE  locationid    = 111
      4  AND    NVL(STATUS,0) = 0
      5  AND    taxid         = 100101
      6  FOR UPDATE;
    no rows selected
    Session2>Of course, this is how it should happen, surely?
    Just to double check, let's reintroduce ROWNUM but force the order by to show it's not about read consistency at the start of the statement - restart should prevent it.
    (reset, then)
    Session1> select t.taxid
      2   from
      3    (select taxid, rowid rd
      4      from   taxids
      5      where  locationid = 111
      6      and    nvl(status,0) = 0
      7      order by taxid) x
      8   ,  taxids t
      9   where t.rowid = x.rd
    10   and   rownum = 1
    11   for update of t.status;
         TAXID
        100101
    Session1>
    --> Yes, session 2 hangs until...
    Session1>BEGIN
      2   UPDATE taxids SET status=1 WHERE taxid=100101;
      3   COMMIT;
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    Session1>
    --> and then
    Session2> select t.taxid
      2   from
      3    (select taxid, rowid rd
      4      from   taxids
      5      where  locationid = 111
      6      and    nvl(status,0) = 0
      7      order by taxid) x
      8   ,  taxids t
      9   where t.rowid = x.rd
    10   and   rownum = 1
    11   for update of t.status;
         TAXID
        100102
    Session2>Session 2 should never be allowed to get 100101 once the lock is released.
    This is a bug.
    The worrying thing is that I can reproduce in 9.2.0.8 and 11.2.0.2.

Maybe you are looking for

  • Exception write to event log when user not found in active directory

    I'm trying to use a exception to write to a event log to show which user did not get imported from my csv file. Any help to write this exception is appreciated. Thanks Import-CSV $importfile | ForEach-Object{ $samaccountname = $_.sAMAccountName.ToLow

  • IN NEED OF HELP PURCHASING A MACBOOK PRO

    Hi! I might buy a Macbook Pro 15 today. It is a late 2008 model brand new. I am wondering if this a deal of a lifetime. I would love any feedback. It costs $1575, would you buy?!? (specs are below) *2.4 GHz Core 2 Duo Processor* *4GB DDR3 RAM* *250GB

  • Help with Java programming project

    Hi, I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream co

  • Duplicate SMS messages

    I have been looking to find a solution to a problem but have not been able to find. Perhaps you can help. I have connected my 3100 phone to PC Suite 6.8 (and previous versions). The problem is that upon synch thru File Manager, SMS messages continue

  • Not able to import SLD objects into Integration Builder

    Hi,    while importing objects from SLD into Integration Builder , am getting no authorization to import objects from SLD. Plz let me know how to solve this issue. Thanks, Satya.