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.

Similar Messages

  • Error occurs when executing an item in an inbox with more than 1000 entries

    Hi Everyone,
    One of our approvers in SRM experienced an error when his inbox contained more than 1000 entries .  Further execution on any inbox item produces errors.
    Would you know where to set the maximum allowable entries in a user's inbox? Can this be set thru SRM config or Basis functionality?
    We also searched for existing SAP Notes but found nothing.
    Your inputs and help are greatly appreciated.
    Thanks and Regards,
    Vhong

    Hello,
    The user has sent me the screen shot. But this has no error messages. The approval transaction shows an ITS screen/code with template 'bbpapproval/99/saplbw02_1200.html'
    However, we have a user in Quality where the page displays with no problem and with 1675 Entries.
    Do you think this is more of an ITS setting or any Template/JavaScript issues?
    I got this code (view source code) earlier today and the topmost header of the code is:
    <!--
    This page was created by the
    SAP Internet Transaction Server (ITS, Version 6200.1025.7214.5, Build 908978, Virtual Server Q36, Add. service info none, WGate-AGate Host esetnmw028, WGate-Instance Q36)
    All rights reserved.
    Creation time:  Mon Mar 15 07:21:39 2010
    Charset:        iso-8859-1
    Template:       bbpapproval/99/saplbw02_1200.html
    -->
    Regarding the not-so-good practice of approvers to have more than 1000 entries in their inbox, we are still in the process of planning on how to divide the task to different approvers since there is only one approver (Project Manager) for the related network.
    Thanks and Redards,
    Vhong

  • How to pass more than one value for one column in procedure

    hi
    select id, name from col_tab where dept_name in ('ECE','CIVIL');
    when i was running this it is working well.
    CREATE OR REPLACE PACKAGE pack_str
    AS
    TYPE type_refcur IS REF CURSOR;
    PROCEDURE str(char_in VARCHAR2,ans OUT type_refcur);
    END pack_str;
    CREATE OR REPLACE PACKAGE BODY pack_str
    AS
    PROCEDURE str(char_in VARCHAR2,ans OUT type_refcur)
    IS
    BEGIN
    OPEN ans FOR
    select id,name from col_tab where dept_name in char_in ;
    END str;
    END pack_str;
    the package was created.
    my doubt is
    1.how to pass more than one value for char_in (e.g ('ECE','CIVIL'))
    2. when i was storing the value in string like val = 'ECE,CIVIL' ,
    how to get the id,name for ECE and CIVIL.
    plz help me

    Hi Rebekh ,
    I am recreating your packages for the desired output.
    CREATE OR REPLACE PACKAGE pack_str
    AS
         TYPE type_refcur IS REF CURSOR;
         PROCEDURE str(char_in VARCHAR2,ans OUT type_refcur);
    END pack_str;
    CREATE OR REPLACE PACKAGE BODY pack_str
    AS
         PROCEDURE str(char_in VARCHAR2,ans OUT type_refcur)
         IS
              lv_t varchar2(200);
         BEGIN
              lv_t := REPLACE(char_in,',',''',''');
              lv_t := 'select id,name from col_tab where dept_name in (''' || lv_t || ''')' ;
              OPEN ans FOR lv_t;
         END str;
    END pack_str;
    Note:-
    Input Parameter char_in is a comma seperated value for dept_name
    -Debamalya

  • How to pass more than one parameter

    Hello,
    This is my code.
    How to pass more than one parameter:
    SELECT:responsibility_name responsibility_name,
    LPAD(' ', 6*(LEVEL-1))
      || menu_entry.entry_sequence sequence ,
      LPAD(' ', 6*(LEVEL-1))
      || menu.user_menu_name SubMenu_Description ,
      LPAD(' ', 6*(LEVEL-1))
      || func.user_function_name Function_Description ,
      LPAD(' ', 6*(LEVEL-1))
      || menu_entry.prompt prompt
      ,menu.menu_id ,
      func.function_id
      --menu_entry.grant_flag Grant_Flag ,
      --DECODE( menu_entry.sub_menu_id , NULL, 'FUNCTION' , DECODE( menu_entry.function_id , NULL, 'SUBMENU' , 'BOTH') ) Type
    FROM fnd_menu_entries_vl menu_entry ,
      fnd_menus_tl menu ,
      fnd_form_functions_tl func
    WHERE menu_entry.sub_menu_id    = menu.menu_id(+)
    AND menu_entry.function_id      = func.function_id(+)
    AND MENU.LANGUAGE(+) = 'US'
    AND FUNC.LANGUAGE(+) = 'US'
    --AND func.user_function_name LIKE '%Primary Care Providers%'
    AND grant_flag                  = 'Y'
      START WITH menu_entry.menu_id =
      (SELECT menu2.menu_id
      FROM fnd_menus_tl menu2,apps.fnd_responsibility_vl resp
      WHERE menu2.menu_id=resp.menu_id
      and resp.responsibility_name= :responsibility_name
      --and menu2.user_menu_name = ('ATCO HR INQ USER'
      AND LANGUAGE = 'US'
      CONNECT BY MENU_ENTRY.MENU_ID = PRIOR MENU_ENTRY.SUB_MENU_ID
       and menu_entry.function_id not in (select func.function_id
                                       from --fnd_form_functions_vl fnc,
                                       apps.fnd_resp_functions exc,
                                       apps.fnd_responsibility_vl res
                                      where func.function_id = exc.action_id
                                      and res.responsibility_name =:responsibility_name
                                      and res.responsibility_id=exc.responsibility_id)
      and menu_entry.sub_menu_id  not in (select menu.menu_id
                                       from --fnd_menus_vl imn,
                                       apps.fnd_resp_functions exc,
                                       apps.fnd_responsibility_vl res
                                       where menu.menu_id = exc.action_id
                                       and res.responsibility_name =:responsibility_name
                                      and res.responsibility_id=exc.responsibility_id)
    ORDER SIBLINGS BY menu_entry.entry_sequence;
    Thank you for your help
    Shuishenming

    Hi, Ming,
    One way is to put the "parameters" in a table, and join to that table in your query.  If you make it a Global Temporary Table, then multiple sessions can run the query at the same time, and each can be seeing different responsibilities.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.  Since this problem involves parameters, you should give a couple of different sets of parameters, and the results you want from the same sample data for each set.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Vector or ArrayList  use for dropdown with more than 1000 entries

    Hi Friends
    I am having more than 1000 entries of different TimeZone's which i need to display in a dropdown list.
    i am not able to decide whether i need to use a Vector or Arraylist for storing these values.
    please let me know which one will be best suited to use in case the list entry is more than 1000 characters.
    waiting for a positive reply from your side.
    Thanks & Regards
    Vikeng

    A JComboBox can be constructed from a Vector (rather than any other sort of List) without having to implement your own ComboBoxModel. (JList is similar).
    I agree with kajbj - a control like this with a thousand entries is rather poor interface design. One exception might be if the entries are sorted in some way, and you "jump" to the appropriate place in the list as the user types.

  • 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.

  • How to pass more than one value to the procedure

    How can I pass more than one letting date to this procedure. If it is only one letting date, I do not have a problem but when it is more than one letting date at the same time then I am stuck. please help
    example I would like to pass this three letting dates : '01/17/2010', '01/27/2010','05/22/2010'
    CEATE OR REPLACE PROCEDURE TPLCP.PLANHOLDERSLIST
    P_LettingDate IN  VARCHAR2,
    p_results OUT sys_refcursor
    AS
    BEGIN
        OPEN p_results FOR
    SELECT DISTINCT DECODE (TRIM (MIN (j.route)), NULL, 'N/A',TRIM (MIN (j.route))) rt,l.lcontid conid,
                     SUBSTR (q.cprojnum, 1, 10) pr, SUBSTR (l.letting, 3, 2)|| '-'|| SUBSTR (l.letting, 5, 2)|| '-'|| SUBSTR (l.letting, 1, 2) lt,
                    (q.cdescr) jbtyp, INITCAP (q.clocat1 || q.clocat2) loc
               FROM vendor v,
                    vendaddr r,
                    letprop l,
                    planhold p,
                    proposal q,
                    project j,
                    propproj k,
                    bidlet bd
              WHERE v.vendor = r.vendor
                AND k.contid = q.contid
                AND k.pcn = j.pcn
                AND l.lcontid = k.contid
                AND p.vendor = v.vendor
                AND l.letting = p.letting
                AND TO_CHAR (bd.datelet, 'MM/DD/YYYY') IN P_LettingDate
                AND l.CALL = p.CALL
                AND r.addrnum = p.billto
                AND bd.letting = l.letting
           GROUP BY v.vendor,
                    r.addrnum,
                    v.vnamel,
                    r.aaddr1,
                    p.billto,
                    r.acity,
                    r.astate,
                    q.cdescr,
                    q.clocat1,
                    q.clocat2,
                    bd.letting,
                    r.azipcode,
                    r.vasst1,
                    r.aphone,
                    l.letting,
                    l.lcontid,
                    q.cprojnum;
    END PLANHOLDERSLIST;

    you can create your on array type and then pass that as the parameter. I use the suffix of ttyp to represent a table type.  The name of the column when using the table() syntax is columnvalue.
    I altered my session to set the default date format to match your format. you could have used the to_date function to set the values for the arr type.
    Hope this helps.
    create type msw_ttyp as table of date
    create or replace
    procedure msw_test(p_arr     in msw_ttyp) as
    v     integer;
    begin
    select count(*)
       into v
       from table(p_arr);
    dbms_output.put_line('count: '||v);
    for rec in (select column_value
                   from table(p_arr))
    loop
      dbms_output.put_line(rec.column_value);
    end loop;
    end msw_test;
    alter session set nls_date_format = 'MM/DD/YYYY';
    set serveroutput on size 1000000
    exec msw_test(msw_ttyp('01/17/2010', '01/27/2010','05/22/2010'));
    begin
    msw_test(msw_ttyp(to_date('01/17/2010', 'MM/DD/YYYY'),
                       to_date('01/27/2010', 'MM/DD/YYYY'),
                       to_date('05/22/2010', 'MM/DD/YYYY')));
    end;
    /

  • How to pass more than 3 Items in link of report attribute?

    I have a report with edit link.
    After user click link, then go to next page. I want to pass more than 3 items in this link, item 1 name=xxx and value=#xxx#.
    How can I do this?
    Thanks.

    Why wouldn't you pass item values through links...is it not why they were created?1. Item values may contain characters that are not URL safe in general ('#') or in APEX (':'), causing the link to fail.
    2. Recognisable item values that are visible in the URL are a security issue, and invite URL tampering that in a poorly designed and implemented system may allow unauthorised access to data.
    3. There are limits on the length of URL APEX, user agents and servers are capable of handling.
    4. Lots of long URLs in links drives up page weight and bandwidth usage.
    5. General housekeeping problems and maintainenance issues: think about going backwards and forwards in single-row APEX URL text item showing 60 chars when making changes to a 2000-character URL.
    Best practice when passing parameters through a URL is to use as few as possible: preferably single, unique, "meaningless" sequence- or sys_guid-generated references.

  • How to pass more than one parameter using common...

    Hi,
    I am using ODP.NET with my 2005 VB
    I want to create function from where I can pass more than one parameter to execute SP, or query just like i created for SQL SERVER as below
    Public shared Function CreateParameter(ByVal paramname As String, ByVal paramvalue As Object) As DbParameter
    Dim param As DbParameter
    param = New SqlParameter
    param.ParameterName = paramname
    param.Value = paramvalue
    Return param
    End Function
    Public Shared Function ExecuteQuery(ByVal sql As String, ByVal commtype As CommandType, ByVal ParamArray parameter As DbParameter())
    Dim cmd As DbCommand = New SqlCommand()
    cmd.Connection = OpenConnection()
    cmd.CommandType = commtype
    cmd.CommandText = sql
    cmd.Parameters.AddRange(parameter)
    Dim RetVal As Integer = cmd.ExecuteNonQuery()
    Return RetVal
    End Function
    specially part is in bold to be converted
    I tried like but oracleCommand.parameters doesnt support AddRange
    please help me out
    Regards

    Hello,
    I used the following way:
    pCommand.CommandText = "Update " + sDataTable + " set "
    + sColumnName + " = :1 ";
    pCommand.Parameters.Add("ValueToDb",
    this.DefaultDbType,
    this.m_Value,
    System.Data.ParameterDirection.Input);
    Of course, you can add :2,... to your command text, too.
    The way back is:
    sEndOfTheClause += " RETURNING " + sDataTable + "." + sColName + " INTO :iNewValue";
    pCommand.CommandText = ... + sEndOfTheClause;
    pCommand.Parameters.Add("iNewValue", this.DefaultDbType,
    ParameterDirection.Output);
    bool bReturn = (pCommand.ExecuteNonQuery() != 0);
    if ((bReturn == true) && (pCommand.Parameters.Count > 0))
    this.Value = DataService.Convert<DATA_TYPE>(pCommand.Parameters[0].Value);
    ....

  • 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);

  • Can columns be more than 1000 in a select query (oracle 11 g)

    I am getting this error: "ORA-01792: maximum number of columns in a table or view is 1000"
    I have a dynamic query where number of column can increase according to the user input.
    They can expect more than 1000 columns. Is it possible to fetch more than 1000 rows in a query?
    I appreciate all your help.
    Edited by: user10232912 on Apr 26, 2012 2:07 AM

    >
    They can expect more than 1000 columns.
    Then they are idiots. IMO.
    Open challenge. Show me an entity with a 1000 attributes and I will show you a flawed data
    model and a total lack of grasping fundamentals of implementing that into a relation database product like Oracle.I second that - as someone who once had to ETL a system which had a table with 35.000 fields - that's 35K.
    It was a system which made extensive use of arrays - and arrays of arrays of arrays...
    Paul...

  • How to get more than 1000 rec from Oracle?

    Hi
    i got this issue from 1 of my fnd.
    can any one tell me how to over come this issue?
    I need help in solving the issue
    This is the oracle error coming when we try to export
    the records to the excel sheet.
    Macromedia][Oracle JDBC Driver][Oracle]ORA-01795:
    maximum number of expressions in a list is 1000
    This error is due to the limitation in oracle db list
    query.
    example:
    select * from FEEDBACK_IN Where feedback_in.case_id
    IN ( (param 1) , (param 2) , (param 3) , (param 4) ,
    (param 5) , (param 6) , (param 7) , (param 8) , (param
    9) , (param 10) , (param 11) , (param 12) , (param
    13)……………………….(param
    5000))
    If the list exceeds 1000, we will get the following
    error from the database. And there is a limitation in
    oracle db to 1000.
    We need to rewrite the query to avoid the list error
    if the list exceeds more then 1000 records.

    You must work with the guy who asked the same question
    yesterday.
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=6&threadid=1149324&ente rthread=y

  • How to pass more than 10 parameters to OnDemand process?

    If have created some application items to use as parameters.
    When I do in my javascript
    get.addParam('F_PAR_REPORT',pReport);
    and I use this parameter in onDemand process as :F_PAR_REPORT , I get
    The requested URL /pls/apex/<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>The requested URL /pls/apex/wwv_flow.show was not found on this server.<P><HR><ADDRESS>Oracle-Application-Server-10g/10.1.2.0.0 Oracle-HTTP-Server Server at kor.ofisa.ch Port 7777</ADDRESS></BODY></HTML> was not found on this server.
    If I use x01 - x10, with iwwv_flow.g_x01, it works, but I need to pass more that 10 parameters.
    Can anyone give me correct syntax? I remember that before v3, there was a possibility, but I don't remember what it was.
    Igor

    Hi Igor
    I'd recommend that you try the following, as this is how I work around the problem:
    Put your items and values into two delimited strings (use javascript arrays and the join function to simplify the process) and set g_x01 for the items and g_x02 for the values, ensuring each named item has a value and vice versa. On thr processing side use the apex_util.string_to_table function and process them, i.e. set session state etc.
    Hope that helps!
    Cheers
    Matt

  • How to pass more than one value in RfcRequest ?

    Hi  Experts,
    I have a FModule (addition) which is exposed as an Enterprise Service. This FM takes two values as input(VAL1 and VAL2) and gives the result (RESULT). I have done the configuration to connect to the backend system via SAP Widget Foundation. When i tried to test in URL :
    http://localhost:7531/SapMiddleTier/REST/ewcs/service/rfct/form , i gave the input for the RFC Query Parameters as : <VAL1>10</VAL1><VAL2>20</VAL2> , but i get an error "Expecting Expression" .
    Am i giving the input in the wrong format ?
    I wrote another FM which doesnt take any input but returns some text as output and  when i queried it via the above URL, i get the correct result. I again tested with changing the Fmodule that accepts one input and returns one output and i find that it returning perfectly.  But when i try with more than one input i get the below error.
    Could some one please help ?
    See the error :
    <?xml version="1.0" encoding="UTF-8"?>
          <root>
             <Status text="expecting expression" code="-1" type="E"/>
             <StatusDetailList>
                <StatusDetail type="I" text="expecting expression" code="0"/>
                <StatusDetail text="" code="0" type="I" source="net.axyana.qizxopen.xquery.XQEvalException: expecting expression at net.axyana.qizxopen.xquery.ext.XfnEval$Exec.eval(XfnEval.java:62) at net.axyana.qizxopen.xquery.op.Expression.evalAsEvents(Expression.java:556) at net.axyana.qizxopen.xquery.op.ElementConstructor.evalAsEvents(ElementConstructor.java:105) at net.axyana.qizxopen.xquery.op.FLWRExpr.evalAsEvents(FLWRExpr.java:423) at net.axyana.qizxopen.xquery.impl.CompiledQuery.evalAsEvents(CompiledQuery.java:82) at net.axyana.qizxopen.xquery.impl.XQueryExprImpl.doExecuteQuery(XQueryExprImpl.java:267) at
    Best Regards,
    Sam..

    Hi John,
    Thank you for your reply.
    Am trying to test my FM(using http://localhost:7531/SapMiddleTier/REST/ewcs/service/rfct/form) as mentioned in this link:
    http://nvpal168.pal.sap.corp:1080/widgetgallery/staticPage.seam?pageId=staticPage9
    I had downloaded the SAP Widget Foundation and its running.
    Using the link : http://localhost:7531/SapMiddleTier/REST/ewcs/service/rfct/form we can test exposed function modules . If you are using SAP Widget Foundation, then the above link will open up a form
    where in the user gives RFC parameters.
    I gave it as <VAL1>10</VAL1><VAL2>20</VAL2> and click on Query RFC = > i get the above mentioned error. If this works, then i can call my function module via Adobe flex using HTTP Service with the service url as "http://localhost:7531/SapMiddleTier/REST/ewcs/service/rfct/form".
    Best Regards,
    Sam.

  • How to put more than 1000 values into an Oracle IN clause

    Is there any way to get around the Oracle 10g limitation of 1000 items in a static IN clause? I have a comma delimited list of many of IDs that I want to use in an IN clause, Most of the times values may exceed 5000. And I don't have privileges to create a temporary table, so that I can put all those in that and run at a time.
    Thanks
    Sreenivas

    Although the trick of using OR would likely work, why don't you use a dynamic collection on the right-hand-side of the where in clause?
    This thread has details Re: Binding collection to right-hand-side of WHERE num_col in (:1) clause?
    Binding a VArray is not super easy, but at least with a bind value (the collection), you can have a single prepared statement, and vary just the collection you pass in. --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for