Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

690485Jul 13 2010 — edited Oct 29 2010
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?
This post has been answered by MichaelS on Jul 13 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2010
Added on Jul 13 2010
7 comments
3,257 views