Can't Exceed 1000 Expressions in Query

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

grimlockpdp

Thread Starter
Joined
Sep 22, 2009
Messages
26
I am trying to run the following query below in Oracle:

Select Acct_Num, Customer_Name
From Database
Where Acct_Num IN (
1,
2,
..,
..,
200001,
200002
)

When I attempt to run the query, I get the error message: "ORA-01795 maximum number of expressions in a list is 1000"


Is there any way I can execute this query w/o having to break the list up by 1,000 Acct_Num over 200 times? Please note that there are more than 200,002 accounts and I just want to extract information on these 200,002 accounts. Thank you!!
 
Joined
Jul 29, 2001
Messages
21,334
If you want all of the account numbers why are you using a where clause? If you know the range of number use a between statement or something like that.
 

grimlockpdp

Thread Starter
Joined
Sep 22, 2009
Messages
26
My example was not very clear. What I meant to say is that the accounts that I wish to retrieve are not all ordered sequentially and mix ranges with accounts that I don't want. Therefore I can't use the between clause.
 
Joined
Jul 29, 2001
Messages
21,334
Is there another filed you can set as a criteria like account type or create your own field based off of another? I kind of figured that was why you were doing it that way.
 

grimlockpdp

Thread Starter
Joined
Sep 22, 2009
Messages
26
Unfortunately I can't use another field(s) to isolate the accounts I want to query. I wish I could though.
 
Joined
Jul 29, 2001
Messages
21,334
Could you use an external table set up just for the account numbers you need to report on and loop through that set of data? I am sure the 10,000 limit is a limitation of the SQL language and there is no way around that. Just have to think outside of the box to get it to work the way you want.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top