More than 1000 record in IN clause

RDBMS : Oracle 10.2
OS : CentOS 5
Hi,
I have a situation where I have to compare more than 1000 ids in my IN clause.
I have used something like
slect col,col2....
from tble ......
where .....
and id in (--first 1000 ids ---)
or id in (--next 1000 ids ---);
the query is taking a lot time. If I omit second IN clause, it executes instantly .
Can you please suggest how to handle such situation ?

Take your full list of 2000 ids, paste them into a program like Notepad++ (or even regular notepad) then use the replace function to replace all commas with: " from dual union all select ". Add "with a as (select " to the front and " from dual)" to the end also add an alias like aid to the first item in the list. Paste that on the front of your query and change your "in" clause to say "id in (select aid from a)"
Then instead of this:
select col,col2
  from tble
where id in (1,2,3,4,5);you'll use this:
with a as (select 1 aid from dual union all
           select 2 from dual union all
           select 3 from dual union all
           select 4 from dual union all
           select 5 from dual)
select col,col2
  from tble
where id in (select aid from a);

Similar Messages

  • Fetch more than 1000 records

    Hi,
    I am using APEX_ITEM.SELECT_LIST_FROM_QUERY_XL(). When I try to fetch more than 1000 records in PL/SQL block .It throws character string buffer too small. I donot know how much records it will fetch because it is dynamically generated.
    could you please anyone help me out.

    Hi
    I agree that a popup LOV would be better, for two reasons:
    1 - Even if you could construct a select list with over 1,000 items, users may find it awkward to use as they would have to scroll to find the item they want - at best they could type in the first character of an item but they'd have to scroll from then on or keep pressing the same character to move down one item at a time.
    2 - The fact that you're using that function to generate the list implies that you are using a tabular form and, therefore, that there will be several instances of the list on your page. If so, the time taken to generate the page and download it may slow page load time considerably.
    If you do need to have select lists, there are techniques that you can use to do this - typically, this would involve creating small lists in the form, a hidden select list created as a normal page item and then using javascript to copy the hidden list items into the tabular form fields.
    Andy

  • Can we upload more than 1000 records with BPS file upload pf

    We are using file upload functionality in BPS. Can we use this function to upload around 80,000 records at a time.
    We are unable to upload more than 1000 records because throws a time out error. Is there a setting that we can change to resolve this?

    Hi,
    Can you check the following note  about BW system parameters :
    [https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=192658]
    Check the work Process time set for your BW system
    Is your application web based ?
    Pratyush

  • How to pass more than 1000 entries in 'IN' clause, Oracle 11g

    Hi All,
    I know this is a very common question in Oracle discussion forum. But, Im in different zone.
    I use C#, .NET and Oracle 11g. I have a situation where I will create a query statement using 'IN' clause in C# code based on my requirement and execute that statement from code itself with oracle connection object. I do not have any procedures. I must phrase my query statement and pass it on to OracleConnection object to execute it.
    My code looks like this....
    List<decimal> x_Ids = new List<decimal>();
    I will load my IDs into x_Ids here;
    string whereInClause = ........I will prepare a 'IN' clause (All IDs separated by ',')
    My query would looks like this....
    string query = select * from MYTABLE where X_ID in [ whereInClause with more than 1000 entries]
    oraConn.ExecuteQuery(query);
    I have a workaround with OR operator with 'IN' clause like below.
    X_ID in [ Ids till 1000 entries] OR X_ID in [Next 1000 entries] OR X_ID in [Next 1000 entries] ....so on.....
    It is working, but, I heard that this may slowdown the performance of the application. Is this really a performance hit to my application?
    Can you please suggest any other workaround to overcome this situation?

    >
    I have a workaround with OR operator with 'IN' clause like below.
    X_ID in [ Ids till 1000 entries] OR X_ID in [Next 1000 entries] OR X_ID in [Next 1000 entries] ....so on.....
    It is working, but, I heard that this may slowdown the performance of the application. Is this really a performance hit to my application?There should be no performance difference between a statement like
    select * from myTab
    where ID in (1,2,3,4,5)
    OR ID in (6,7,8,10,12) and
    select * from myTab
    where ID in (1,2,3,4,5,6,7,8,10,12) The execution plan should be identical.
    However those values might better be send as a single object (collection or table of numbers type).
    I think the ODP or OO4O connectivity allows to create and such oracle object types.
    Another way could be to think about how all the values are created? Did any user enter them manually? Certainly not. Then maybe you can apply the same logic to the SQL statement that created those values in your .Net application.
    something like
    select * from myTab
    where ID in (select t2.FK_ID from otherTab t2 where t2.Col1 = 100) This approach would probably beat all others performancewise. Since you avoid the overhead of constructing the in-lists.

  • LSMW not creating session for more than 1000 records

    Hi all
    I am doing LSMW for equipment creation (IE01) using recording
    all are correct if i upload I have 2400 records to be uploaded,in the last step
    it showing "BDC_Insert,Transcation is invalid"
    If i upload for less then 1000 records like 950, its succefully creating
    sessions.
    PLease its very urgent, let me know
    Thanks in advance

    Hi Chandra,
    In filed mapping step END_OF_RECORD change the value of field g_cnt_transactions_group to value more than 5000. I think this value is less than 1000 for your case.
    at_first_transfer_record.           
    if g_cnt_transactions_group = 5000. 
      g_cnt_transactions_group = 0.     
      transfer_record.                  
    endif.                              
    If you are not able to see the END_OF_RECORD  in field mapping do the following steps:
    Extras menu-> Layout check all check boxes it will appear.
    Regards,
    Rajesh Sanapala.

  • SQL select query having more than 1000 values in 'IN' clause of predicate.

    Hi,
    We are executing a select query from a table and showing it through a front end screen. When the count of values given in the 'IN' clause of predicate are exceeding 1000 , it is throwing error.
    eg. select * from Employees where emp.Id. in('111',123','121','3232',........1001 Ids)
    We are using Oracle version 10.2.0.
    Please suggest how to tackle such issue.
    Regards,
    Naveen Kumar.C.
    Edited by: Naveen Kumar C on Aug 30, 2008 10:01 PM

    Use a nested table:
    create or replace type numbertype
    as object
    (nr number(20,10) )
    create or replace type number_table
    as table of numbertype
    create or replace procedure tableselect
    ( p_numbers in number_table
    , p_ref_result out sys_refcursor)
    is
    begin
    open p_ref_result for
         select *
    {noformat}     from   employees
         ,        (select /*+ cardinality(tab 10) */ tab.nr
                   from   table(p_numbers) tab) tbnrs
         where id = tbnrs.nr;
    end;
    /{noformat}
    Using nested tables will reduce the amount of parsing because the sql statement uses binded variables! The cardinality hint causes Oracle to use the index on employees.id.

  • Handeling more than 1000 columns in where clause

    Hi,
    I am using oracle 9i. We are creating a select query and adding where clause at runtime.
    The no of clolumns in where clause depends on the results from another enterprise app. There may be any no of columns from 0-N. Till 1000 columns every thing works fine but when it goes beyond 1000 it gives the following error:
    ERROR:
    java.sql.SQLException: ORA-01795: maximum number of expressions in a list is 100
    0
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2321)
    at oracle.jdbc.oci8.OCIDBAccess.parseExecuteDescribe(OCIDBAccess.java:12
    55)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.jav
    a:2391)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
    nt.java:2672)
    at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:
    572)
    Please help.
    Thanks in advance.

    Thanks Archana,
    You are right.
    I think i have not framed my question right.
    Actually its problem with "IN", which i am using in where clause. It working properly till 1000 expressions like "select * from foo where fooid in (n0,n1,n2......,n1000)".
    But throwing exception once the count increases to 1000 like
    "select * from foo where fooid in (n0,n1,n2......,n1000,n1001,n1002)".
    Thanks,
    Mukesh

  • Error while fetching more than 1000 mysql records

    I'm trying to fetch data from a MySQL database through PHP to a Flex application. When there are more than 1000 records in the resultset, the FaultEvent is returned. When I limit it to 1000 records, no problem at all. Any ideas? Code below:
    public function OldCustomerService(method:String=HTTPRequestMessage.POST_METHOD, resultFormat:String=RESULT_FORMAT_E4X, showBusyCursor:Boolean=true)
                super(null, null);
                this.requestTimeout = 0;
                this.method = method;
                this.resultFormat = resultFormat;
                this.showBusyCursor = showBusyCursor;
            public function getAllProspects():void {
                this.url = ALL_PROSPECTS_URL;
                this.addEventListener(ResultEvent.RESULT, getAllProspectSuccess);
                this.addEventListener(FaultEvent.FAULT, DAOUtil.communicationError);
                var oldCustomersToken:AsyncToken = this.send();

    It works with fewer records so it would be weird if it would be a php or mysql error. Seems to me Flex isn't waiting until everything is in. To give you a better idea of what's happening, I'll post the PHP code:
    <?php
    * Created on 19-mrt-10
    * To change the template for this generated file go to
    * Window - Preferences - PHPeclipse - PHP - Code Templates
         include '../../application/general/php/general.php';
         // connect to the database
         $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
        // select the database
        mysql_select_db( DATABASE_NAME );
        // query the database to retrieve all customers.
        $query = "SELECT * FROM stores";
        $result = mysql_query($query);
        //start outputting the XML
        $output = "<result>";
        if($result) {
            $output .= "<success>yes</success>";
            $output .= "<stores>";
            // create a store tag for each retrieved store
            while($customer = mysql_fetch_object($result)) {
                $output .= "<store>";
                $output .= "<naam>$customer->naam</naam>";
                $output .= "<adres>$customer->adres</adres>";
                $output .= "<postc>$customer->postc</postc>";
                $output .= "<wpl>$customer->wpl</wpl>";
                $output .= "<land>$customer->land</land>";
                $output .= "<telprive>$customer->telprive</telprive>";
                $output .= "<telbureau>$customer->telbureau</telbureau>";
                $output .= "</store>";
            $output .= "</stores>";
        } else {
            $output .= "<success>no</success>";
            $output .= "<error>\n";
            $output .= "Reason: " . mysql_error() . "\n";
            $output .= "Query: " . $query ."\n";
            $output .= "</error>";
        $output .= "</result>";
        print ($output);
        mysql_close();
    ?>
    When the error occurs, I get a <success>yes</success> and yet again the Fault error is thrown. Again, with fewer records, no problem.

  • More than 1000 values

    Dear All,
    I am using oracle 10g with odp.net. I have values more than 1000 to be passed in the IN condition. How do i achieve this. When i pass the values it says only 1000 parameters are allowed in the IN condition.
    Please let me know.
    Regards
    Fkhan

    fkhan wrote:
    What i have thought of is to insert all the selected values in a global temporary table and then in my procedure use the subquery and use the values from the global temporary table.A better approach than using a massive IN list of values. But still problematic ito having a user interface deal with a 1000+ item/code selection. Still a performance problem shipping that amount of data across the network every single time from every single client running this app. And still a flawed ito data modelling and 3NF.
    The correct approach would be permanent tables to deal with this. In its basic and simplest form:
    // defines a keyword for a 1000+ items/codes
    KEYWORDS = ( keyword_id, keyword_description )
    // associates a keyword id with an item/code id
    KEYWORD_MAP = ( keyword_id, code_id )The user interface displays the keyword description. The select clause uses the keyword_id to select from the KEYWORD_MAP the associated list of values as filter criteria for the main query (using a join or IN sub-select for example).
    If the keyword is more complex than this basic approach (e.g. partially dynamic and specific per user), then this basic approach can be extended to serve as a "+favourites per user+" list (kind of like bookmarks, but per individual user). Or designed as to cater for the business requirements.
    But as you have (very simplistic I realise) describe the problem so far, I do not see a problem as much as a basic flaw in your code and data model.
    A user interface for entering and selecting 1000+ codes is clunky. And slow. Sending that data across to Oracle is slow. Inserting that each time around into a temp table for use, is slow.
    There's a lot of moving parts here. And that always contributes in degrading performance and making stuff complex (and usually unnecessarily so).

  • IN operator with more than 1000 values

    Hi,
    For a given list of IDs (PKs), I need to fetch the corresponding rows.
    The problem is that I have more than 1000 values and as far as I know that IN operator is limited to 1000
    values.
    I thought about using UNION such that each Select contains up to 1000 IDs.
    example":
    select * from temp where id in(1....1000)
    union all
    select * from temp where id in(1001....2000)
    Is there a better way to do that?
    Thanks
    dyahav

    As others have presented technical solutions, i'll present you a logical one (seemingly logical anyways, but it will depend on your application).
    I have seen some applications where you get
    select * from some_table where ... <conditions>;That result set is returned to the front end and presented to the users who then pick a series of records and submit another request to the database which ends up being...
    --note, this could be a many table join, with lots more information that just the some_table, this is illustrative only
    select * from some_table where pk_value in (super_super_duper_list_based_on_last_result_set);If this mimics what you have in your application, i'd recommend just fixing it so the users can select a reasonable set of data, OR the entire set (in the last case you'd just send the <conditions> instead of a massive list of PK values).
    Again, highly speculative but i thought i'd mention it in the off chance it's useful to you.

  • How to create more than 1000 entitie in FDQM

    Hi Gurus
    1.How to load locations to FDQM without manual Entry?
    Can we load locations by using flat files?
    Requirement: I have to create more than 1000 entities in FDM Application for mapping Target in HFM Application.
    How to achieve this?
    regards
    Dev

    Two things :
    #1 - The tables you need to add data to are : tPOVPartition, tStructPartitionHierarchy, tStructPartitionLinks. The first table is the basic location information. The last two tables define the relationship hierarchy of where the locations belong. I would expect that if the Strcut information is missing, FDM will not be able to place it anywhere on the locations screen.
    Additionally, for the tPOVPartition, there is required information and you need to make sure you are including all of that info when you create your record.
    #2 - If you are handy at coding, I'm positive there is an API call to create a location. It would make more sense perhaps to write a script that uses the APIs to create the locations so that you can be sure that it is being done right.

  • SEGMENT MORE THAN 1000 BYTES

    ANY ONE  CAN TELLM WT WE HAVE TO DO IF THE SEGMENT HAVING MORE THAN 1000 BYTESOF DATA IN IDOCS
    Moderator message : Search for available information, do not use all capitals.  Thread locked.
    Edited by: Vinod Kumar on Aug 23, 2011 2:33 PM

    Hi,
        The EDIDD (Data record (IDoc)) has a component SDATA which is of length 1000 LCHR. I think that is the maximum limit provided by SAP. I would say if the data in the IDOC is more than that we rather split it in two different segments.

  • Save More than 1000 chars in a field of (Z) Database Table?

    Hi Friends,
    I created a database table with few fields. In the table, one field is REMARKS which should save more than 1000 characters for every record. For that field,  I created domain & data element of char with 2000 length. But system gives an error representing that "Should not be more than 255 chars ".
    Even, select statement is also retrieving 132 chars only, if remarks are less than 255 and greater than 150 chars.
    Could you please provide me solution?
    Thanks
    Sarayu

    Hi,
    The Most simple solution for it can be that Divide the field REMARKS of size 1000 in multiples of 200 characters like REMARK1, REMARK2....REMARKn.
    Now you can create two FMs :
    zset_data:  To Store 1000 char long data in Table
    Here you will divide the data of Variable (type char1024) in multiples of 200 and will store in REMARK1, REMARK2.....
    zget_data: To Get 1000 char long data back from Table
    Here you will concatenate REMARK1, REMARK2..... and will store in Variable of Type char1024.
    This is the best solution if Table is not going to be maintained by Table Maintenance Generator.
    Thanks
    Ajay

  • How to show more than one record at a form-like style report?

    Hi All,
    I developed a form-like style report
    I want it to show more than one record at once (At the same page)
    I tried that by setting the value to "Maximum records per page" property for the repeating frame to 10
    but when I close the property palete and open it agian the value is returned to 1 !!!
    how to show more than one record at the same page?????
    Thank u

    Hi,
    there's perhaps another property like "page protect". If than 2 records didn't fit at one page there's a page break. Or is there any object inside the repeating frame with page-break properties? Sorry .. it's like looking into a chrystal ball ...
    Regards
    Rainer

  • Master_detail for more than one record at a time

    Hi,
    How can i display master_detail records for more than one records at a time, for example, i have two tables A and B , A has username and role and B has username and profile. here i wanted to display 10 users at a time on my 6i form with username, role and profile.
    i have created a master-detail relation ship with these tables when i'm executing F8 on blcok A , it displays 10 records on BlockA but, only one at a time on block B, how can i display all corresponding records on block B at a time.
    Thanks for your help.Bcj

    Thanks Roberts, that was realy informative due to some doubts i would like to confirm my requirements , i have two blocks A and B and each master record has only one detail record. but i wanted to display at least 10 master_detail relationships(records) on the form at a time, i would like to know is it possible to do without creating any table or view for example,
    data in table A,
    username role
    AAA R1
    BBB R2
    CCC R3
    data in table B,
    username profile
    AAA P1
    BBB P2
    CCC P3
    i wanted to display it on form like below,
    username role profile
    AAA R1 P1
    BBB R2 P2
    CCC R3 P3
    Also would like to know that how can i select data from dba_users, any restriction is there on forms 6i, i can select it on sqlplus.
    Thanks Again, Bcj

Maybe you are looking for