Why does my IN operator change the datatype

Hi
This doesn't make any sense, but i'm hoping there's an obvious answer which you guys have seen a million times before.
I have this criteria in my WHERE clause
AND rpg_id = (SELECT rpg_id
                                         FROM integration.rep_elig_groups
                                        WHERE pel_id IN(34))because of this clause no results are return in my query. However if i use a to_number function like this:
AND rpg_id = to_number(SELECT rpg_id
                                         FROM integration.rep_elig_groups
                                        WHERE pel_id IN(34))OR
AND to_char(rpg_id) = (SELECT rpg_id
                                         FROM integration.rep_elig_groups
                                        WHERE pel_id IN(34))i get the expected results returned.
The sub query:-
SELECT rpg_id
                                         FROM integration.rep_elig_groups
                                        WHERE pel_id IN(34)returns the value 226. rpg_id in this table is a NUMBER datatype. As is rpg_id in the original outer query.
I looked at synonyms, views, and other objects it might be using for the rep_elig_groups table, but there are none.
Then i tried changing the IN operator for an EQUALS operator and would you believe it, it worked.
AND rpg_id = (SELECT rpg_id
                                         FROM integration.rep_elig_groups
                                        WHERE pel_id IN(34))can someone please explain what ORACLE is thinking here!!!
Many thanks
Edited by: tri_harder on Dec 9, 2008 4:48 PM missed the closing bracket in the final piece of code!
Edited by: tri_harder on Dec 10, 2008 8:44 AM

I ran the expain plans in TOAD for both queries, with the only difference changing the operator from IN to =. I'm very surprised there is such a difference between the two!!
SELECT   tim_id,
              rpg_id,
                             ROUND(SUM(retail_value), 2) retail_value,
                             ROUND(SUM(salesidx), 2) salesidx,
                             ROUND(SUM(VALUE), 2) VALUE,
                             ROUND(SUM(bva_salesidx), 2) bva_salesidx,
                             ROUND(SUM(bva_value), 2) bva_value,
                             ROUND(SUM(bva_retail_value), 2) bva_retail_value
                        FROM ms_stats_ol_ms
                       WHERE 1 = 1
                         AND fmt_id IN(SELECT ID
                                         FROM formats
                                        WHERE car_id = 0 OR 0 = 0)
                         AND fmt_id NOT IN(
                               SELECT fmt.ID
                                 FROM formats fmt,
                                      class_formats clf
                                WHERE fmt.ID = clf.fmt_id
                                  AND clf.cla_id IN(3, 6)
                                  AND fmt.car_id = 2)
                         AND cla_id = 3
                         AND rpg_id = (SELECT rpg_id
                                         FROM rep_elig_groups
                                        WHERE pel_id IN(34))
                         AND tim_id BETWEEN 4985 AND 5418
                    GROUP BY tim_id, rpg_idSo this is my original query that returned no results and produced the following Explain Plan:-
Plan
SELECT STATEMENT  ALL_ROWSCost: 10,842  Bytes: 1,505  Cardinality: 35                                          
     17 HASH GROUP BY  Cost: 10,842  Bytes: 1,505  Cardinality: 35                                     
          16 HASH JOIN  Cost: 10,836  Bytes: 1,587,345  Cardinality: 36,915                                
               1 TABLE ACCESS FULL TABLE INTEGRATION.FORMATS Cost: 2  Bytes: 90  Cardinality: 15                           
               15 HASH JOIN RIGHT ANTI  Cost: 10,833  Bytes: 1,456,912  Cardinality: 39,376                           
                    6 VIEW VIEW SYS.VW_NSO_1 Cost: 4  Bytes: 6  Cardinality: 2                      
                         5 HASH JOIN  Cost: 4  Bytes: 24  Cardinality: 2                 
                              2 TABLE ACCESS FULL TABLE INTEGRATION.FORMATS Cost: 2  Bytes: 12  Cardinality: 2            
                              4 INLIST ITERATOR            
                                   3 INDEX RANGE SCAN INDEX (UNIQUE) INTEGRATION.CLF_PK Cost: 1  Bytes: 60  Cardinality: 10       
                    14 TABLE ACCESS BY INDEX ROWID TABLE CHARTDEV.MS_STATS_OL_MS Cost: 10,829  Bytes: 1,530,034  Cardinality: 45,001                      
                         13 BITMAP CONVERSION TO ROWIDS                 
                              12 BITMAP AND            
                                   8 BITMAP INDEX SINGLE VALUE INDEX (BITMAP) CHARTDEV.MSST_OL_MS_RPG_ID_I      
                                        7 INDEX FAST FULL SCAN INDEX (UNIQUE) INTEGRATION.REG_PK Cost: 2  Bytes: 6  Cardinality: 1 
                                   10 BITMAP MERGE       
                                        9 BITMAP INDEX RANGE SCAN INDEX (BITMAP) CHARTDEV.MSST_OL_MS_TIM_ID_I
                                   11 BITMAP INDEX SINGLE VALUE INDEX (BITMAP) CHARTDEV.MSST_OL_MS_CLA_ID_I      The following script has the very small change of the operator changed from IN to =
SELECT   tim_id,
              rpg_id,
                             ROUND(SUM(retail_value), 2) retail_value,
                             ROUND(SUM(salesidx), 2) salesidx,
                             ROUND(SUM(VALUE), 2) VALUE,
                             ROUND(SUM(bva_salesidx), 2) bva_salesidx,
                             ROUND(SUM(bva_value), 2) bva_value,
                             ROUND(SUM(bva_retail_value), 2) bva_retail_value
                        FROM ms_stats_ol_ms
                       WHERE 1 = 1
                         AND fmt_id IN(SELECT ID
                                         FROM formats
                                        WHERE car_id = 0 OR 0 = 0)
                         AND fmt_id NOT IN(
                               SELECT fmt.ID
                                 FROM formats fmt,
                                      class_formats clf
                                WHERE fmt.ID = clf.fmt_id
                                  AND clf.cla_id IN(3, 6)
                                  AND fmt.car_id = 2)
                         AND cla_id = 3
                         AND rpg_id IN (SELECT rpg_id
                                         FROM rep_elig_groups
                                        WHERE pel_id IN(34))
                         AND tim_id BETWEEN 4985 AND 5418
                    GROUP BY tim_id, rpg_idAnd this returned the expected results and produced the following Explain plan:-
Plan
SELECT STATEMENT  ALL_ROWSCost: 10,996  Bytes: 1,610  Cardinality: 35                                                    
     30 TEMP TABLE TRANSFORMATION                                               
          10 LOAD AS SELECT SYS.SYS_TEMP_0FD9D6614_166B4444                                         
               9 MERGE JOIN CARTESIAN  Cost: 6  Bytes: 570  Cardinality: 30                                     
                    5 VIEW VIEW SYS.VW_NSO_1 Cost: 4  Bytes: 26  Cardinality: 2                                
                         4 HASH JOIN  Cost: 4  Bytes: 24  Cardinality: 2                           
                              1 TABLE ACCESS FULL TABLE INTEGRATION.FORMATS Cost: 2  Bytes: 12  Cardinality: 2                      
                              3 INLIST ITERATOR                      
                                   2 INDEX RANGE SCAN INDEX (UNIQUE) INTEGRATION.CLF_PK Cost: 1  Bytes: 60  Cardinality: 10                 
                    8 BUFFER SORT  Cost: 6  Bytes: 90  Cardinality: 15                                
                         7 TABLE ACCESS BY INDEX ROWID TABLE INTEGRATION.FORMATS Cost: 1  Bytes: 90  Cardinality: 15                           
                              6 INDEX UNIQUE SCAN INDEX (UNIQUE) INTEGRATION.FMT_PK Cost: 0  Cardinality: 1                      
          29 HASH GROUP BY  Cost: 10,990  Bytes: 1,610  Cardinality: 35                                          
               28 HASH JOIN  Cost: 10,989  Bytes: 4,600  Cardinality: 100                                     
                    11 TABLE ACCESS FULL TABLE (TEMP) SYS.SYS_TEMP_0FD9D6614_166B4444 Cost: 2  Bytes: 180  Cardinality: 30                                
                    27 HASH JOIN RIGHT SEMI  Cost: 10,987  Bytes: 34,280  Cardinality: 857                                
                         12 INDEX FAST FULL SCAN INDEX (UNIQUE) INTEGRATION.REG_PK Cost: 2  Bytes: 6  Cardinality: 1                           
                         26 TABLE ACCESS BY INDEX ROWID TABLE CHARTDEV.MS_STATS_OL_MS Cost: 10,984  Bytes: 1,310,574  Cardinality: 38,546                           
                              25 BITMAP CONVERSION TO ROWIDS                      
                                   24 BITMAP AND                 
                                        16 BITMAP MERGE            
                                             15 BITMAP KEY ITERATION       
                                                  13 INDEX FAST FULL SCAN INDEX (UNIQUE) INTEGRATION.REG_PK Cost: 2  Bytes: 6  Cardinality: 1 
                                                  14 BITMAP INDEX RANGE SCAN INDEX (BITMAP) CHARTDEV.MSST_OL_MS_RPG_ID_I
                                        18 BITMAP MERGE            
                                             17 BITMAP INDEX RANGE SCAN INDEX (BITMAP) CHARTDEV.MSST_OL_MS_TIM_ID_I      
                                        22 BITMAP MERGE            
                                             21 BITMAP KEY ITERATION       
                                                  19 TABLE ACCESS FULL TABLE (TEMP) SYS.SYS_TEMP_0FD9D6614_166B4444 Cost: 2  Bytes: 13  Cardinality: 1 
                                                  20 BITMAP INDEX RANGE SCAN INDEX (BITMAP) CHARTDEV.MSST_OL_MS_FMT_ID_I
                                        23 BITMAP INDEX SINGLE VALUE INDEX (BITMAP) CHARTDEV.MSST_OL_MS_CLA_ID_I           Can anybody suggest what's going on?? Why do i get results with one and not the other!!
Edited by: tri_harder on Dec 10, 2008 10:00 AM
altered the first query to change the IN operator to =

Similar Messages

  • Why does "theme" doesn't change the fonts?

    I have imported a powerpoint presentation, yet when I choose a specific theme, it only changes the background and not the fonts. Do you know why? What can I do to fix it? Is there any easy way to replace all fonts and colors?
    Thank you!

    You should also ask this in the MacBook Pro forum. This is the forum for the 13” white and black plastic MacBooks that were discontinued in 2010 and didn't have the illuminated keyboard. You should also post this question there to increase your chances of getting an answer.
    https://discussions.apple.com/community/notebooks/macbook_pro

  • Why does Ical want to change the original dates to 2001 when syncing from my iPhone?

    Hi I was wondering if anyone could help with this as its driving me up the wall
    over the last few weeks I upgraded to Lion running 10.7.1 and until then my Iphone synced everything fine without any problems I have an Iphone 3G running 4.2.1 and when I sync now I get the Ical sync alert saying that more than 25% of my calender events will change on my computer.
    When I look nothing has changed accept the origianl date which is 1/1/2001 for anything that is being taken off my phone onto Ical and also for anything that is already on Ical, I keep telling it to sync later but everything I try it always comes up the same.
    I asked during the week in at the Apple store but was adviced that this problem had not been heard of before and to book both my phone an macbook in for a genius bar appointment.
    Anyone else come accross this problem or is it just myself?
    Kind regards Andy ;0)

    Anyone able to help with this problem at all its still doing my head in ;0(

  • HT2513 Why does Calendar (iCloud) always change the colour of my Work calendar?

    Calendar allows me to set the colour, but next time I am back to check my calendar, the colour has changed.  This happens on both my Mac and iCloud calendars.  I also susbcribe to a Google set of calendars.  Thanks.

    Hello;
    To be honest with you, I've never heard of such thing.
    Since the board you are using is an analog output board, it contaims only output channels, therefore, only analog output program samples will work with it.
    You shouldn't have to worry about any extra configuration of the DACs.
    Regards
    Filipe A.
    Applications Engineer
    National Instruments

  • Why does my voice effect change the way my music sounds too?

    I have an instrumental track that I was recording my voice over and I put my vocals in the Mouse Effect. When I played it back my music was in the mouse effect too. How can I just have my voice in Mouse effect and my music with no effect when I record? It says no effect on the music track, but it still sounds like a mouse.

    No. I notice that it only happens when I split the track. I wanted the music to start at a certain point so I split it so it would start in the middle.

  • Why Acrobat x professional is changing the text formatting specifically the font family  and the font size of the text in my pdf on exporting it to Microsoft word file format ?How should i stop Acrobat x professional from doing that so that i get an exact

    Why Acrobat x professional is changing the text formatting specifically the font family  and the font size of the text in my pdf on exporting it to Microsoft word file format ?How should i stop Acrobat x professional from doing that so that i get an exactly same word file on exporting it from its pdf counterpart?

    I was testing the preciseness & efficiency of Adobe acrobat x professional's doc conversion capabilities. As i have to take a document editing project in future which is going to need lot of pdf to word and vice versa conversions . What I did was I created a test word document converted into a pdf using a pdf maker in my word 2007 , Acrobat did convert the document from word to pdf keeping everything in the source file intact , However when i tried the other way round and attempted to convert the same pdf to word 2007 file format I lost my formatting ?So the font that I used to create the pdf are the ones taken from word 2007 which i believe is using the fonts that are installed in my computer. Any suggestions on how to preserve the formatting of the document after converting it from pdf to word file format?
    Regards
    Mike

  • Why does installation not start after the message "setup wants to make changes"?

    Why does installation not start after the message "Setup wants to make changes.  Type your password to allow this"?

    Hi
    It wants your system's admin password. Standard procedure on Mac for non-admin users
    Thanks

  • Why does Adobe sendnow work and the newest and greatest Adobe Send does not work?

    Why does Adobe sendnow work and the newest and greatest Adobe Send does not work? I wasted about 8 hours on trying to get Adobe Send to upload 269 files that amounted to 469MB. When it did not work I made a zip file and after a lot of wasted run time that did not work. The first situation gives little indication of when a file is loaded compared to Adobe SendNow. In both cases with Send it failed with a message like only the first 50 can be loaded. When I went and looked none of them had been loaded. With the zip file (I wanted to hide the individual files so they would not be counted) it appeared to work but very slowly and finally said it was done and I went and looked and it had done anything for oever 2 hours except a false "I'm runninng" indication.
    Thus, I took a chance with Adobe SendNow and it works great. It never gave me a limit on the amount of files nor on the size of the complete job. It shows me one file at a time when it has finished with the file uploading it. SendNow has never given me any problems.
    Why woiuld you want to change the program from SendNow to Send without the newest program being the best, fastest, user friendly program of the two? It just doesn't make sense to me. I suggest that Adobe keep SendNow working until Send is fixed. I would also suggest that SendNow and how it looks be kept, called Send, then modify Send one thing at a time until you get it to the point you need it to be for Acrobat. I have heard nothing good and now I have experienced it that Send is a piece of junk. I wasted most of my work day on giving Adobe the benefit of the doubt to find out I made a very bad decision to trust Adobe to make good decisions on the transfer of a function to another place .... both Adobe's responsibility.without making it painless for your customers that totally rely on you. Don't throw away customer confidence as it is very hard to get it back.

    Funny how you answer to "troll". (What's your handle on AT&T forums?)
    Yep! Verizon living up to it's contractual obligations by not releasing updates. Caveat emptor!
    I think there are some reasonable expectations here to keep customer's happy. When one carrier offers upgrades there is an expectation the same will happen across all the carriers. We have seen that except Big Red.
    Verizon could have said the update is in MS court months ago and stilled the voice of the disgruntled, or at least redirected it, but instead chose to be silent. Not for market share but for partial blame I think.
    We will have to agree to disagree since you only see Terms & Conditions and I, see customer satisfaction.

  • Why does my mouse pointer change from a hand to a downward facing arrow sometimes?

    why does my mouse pointer change from a hand to a downward facing arrow sometimes?

    the-edmeister, you are a genious. I went to "view" then "toolbars" and de-selected "yahoo toolbar" and then moved the curser over my firefox page and it now works completely including the problem area (the top 3 cm of each screen). Thank you, thank you, thank you, thank you, thank you, thank you. You have no idea how good I feel know on this otherwise cold, windy and rainy day.

  • Change the datatype of all the columns

    Oracle version 10g.
    I have a table with 150 columns.
    I'd like to change the datatype of all the columns in my table to varchar.
    Do we have a query for this task?
    Thanks.

    Not knowing yet what you'll answer to John:
    If your table is empty, you can use the datadictionary to generate a statement and execute it using dynamic SQL or spool the query to a file that does the DDL and run that...
    Example:
    MHO%xe> create table bla (col1 number, col2 number);
    Tabel is aangemaakt.
    MHO%xe> select column_name, data_type from user_tab_columns where table_name = 'BLA';
    COLUMN_NAME                    DATA_TYPE
    COL1                           NUMBER
    COL2                           NUMBER
    MHO%xe> declare
      2    l_sql varchar2(4000);
      3    l_sep varchar2(1);
      4  begin
      5    l_sql := 'alter table BLA modify ('||chr(10);
      6    for rec in ( select column_name from user_tab_columns where table_name = 'BLA')
      7    loop
      8      l_sql := l_sql||l_sep||' '||rec.column_name||' varchar2(50)'||chr(10);
      9      l_sep := ',';
    10    end loop;
    11    --
    12    dbms_output.put_line(l_sql||' )');
    13    --
    14    execute immediate l_sql||' )';
    15    --
    16  end;
    17  /
    alter table BLA modify (
    COL1 varchar2(50)
    , COL2 varchar2(50)
    PL/SQL-procedure is geslaagd.
    MHO%xe> select column_name, data_type from user_tab_columns where table_name = 'BLA';
    COLUMN_NAME                    DATA_TYPE
    COL1                           VARCHAR2
    COL2                           VARCHAR2

  • Why does Lion KEEP reversing changes you make in address book and other applications without your consent and without wanting it to??? Plus address book will NOT import old address book contacts from Snow Lepoard 10.6 and keep them.  This Lion OXS 7 is ..

    Why does Lion KEEP reversing changes you make in address book and other applications without your consent and without wanting it to??? Plus address book will NOT import old address book contacts from Snow Lepoard 10.6 and keep them.  This Lion OXS 7 is .. becoming very frustrating ... it will NOT keep changes made in the Address Book and it has destroyed my contacts which I only have electronically since 10.4 in my address book. I am NOT happy with this OS7 it has a lot of issues and faults.  How can one stop automatic reversing of data when inputting???
    Please help! 
    Wished I NEVER upgraded to this Lion!!!
    Carmelo

    Relax. Your address book database is corrupted.
    If you are syncing your Contacts with MobileMe or something else, disable it for now.
    Backup your address book by going to File>Export>Address Book Archive.
    Quit Address Book.
    Open your Library by holding down the Option (alt) key while selecting the Go menu in Finder. Select Library. Navigate into your Application Support/AddressBook folder and delete the addressbook-v22.abcddb file.
    Open Address Book. It will recreate the database from the raw data.
    See how that works. If it is ok, then reenable syncing and see how that works.

  • Why does my iphone 4s repeat the words I text?

    Why does my iphone 4s repeat the words I text?

    It was when I was typing the text.  I found the answer in the "More Like This" area on the side.  I swear my phone changes settings by itself!  :-)  Thanks!!!

  • I udate my os to 10.6.7 and since then my Pages have color problems. The text is not visible (white on white background) it does'nt help to change the text color nor background color. Pls help

    I udate my os to 10.6.7 and since then my Pages have color problems. The text is not visible (white on white background) it does'nt help to change the text color nor background color. I just download the recent trail version of Iworks and install it. The first document I opened it was ok. When I open the second one the problem appear again and stayed. Pls help

    This behavior was described many times.
    In every occurrence,the operating system was an uncompleted one resulting of the use of Software Update to update the operating system to 10.6.2, 10.6.3, 10.6.4, 10.6.5, 10.6.6, 10.6.7.
    In such cases, the solace was to apply a combo updater.
    As you are using 10.6.7, download and apply the combo 10.6.7 :
    http://support.apple.com/kb/DL1361
    After that, run Software Update which will urge you to apply :
    Snow Leopard Font Update
    Yvan KOENIG (VALLAURIS, France) dimanche 29 mai 2011 21:15:58
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Why does my iPad keep losing the wifi every few minutes?

    Why does my iPad keep losing the wireless connection every few minutes?

    Could be
    1 the routers firmware require an Update
    2 the iPad is defect

  • Why does my ipad drop off the Internet frequently?

    Why does my ipad drop ff the Internet frequently? It will be going fine then just won't connect

    Could be interference from something near you like a cordless phone, etc.

Maybe you are looking for

  • Error in XSQL Sample code ?!

    Hi, I recently tried the XSQL sample code with the latest (1.0.0.0 ?) version of the XSQL sevlet. But there seems to be an error in the example: In the hotels.xsql file (inside XSQLSample.jar, inside XMLUtilitySamples.zip) the query tags are specifie

  • J2EE SERVER 0 not running after ADS Update

    Hi Experts, I have updated ADS patch 10 in our server, but ADS update terminated after that J2ee server not comming up. Please find the Log file. trc file: "D:\usr\sap\MID\DVEBMGS01\work\dev_server0", trc level: 1, release: "700" node name   : ID1758

  • What is the best way to add multiple images with links into an email signature?

    I created an email signature with five linked images by: * creating new message • attached the image • adding link to the image • copied new email signature • under Preferences/Signature added the new signature It all works, but some of the emails bo

  • Variable nr of params in SQLJ

    Hi, I'm using SQLJ for some time now, and it works great.. There is however something that I can't seem to do in SQLJ.. Suppose my query is the following: SELECT * FROM table WHERE nr IN (3,5,6); How can I do this in SQLJ and have 3,5,6 come from jav

  • DYNAMIC TABLE FUNCTION

    Hi Expert I want to build a function that receive a dynamic table , how i do it and how i call this function thanks and regardes