1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Can't Exceed 1000 Expressions in Query

Discussion in 'Business Applications' started by grimlockpdp, Nov 18, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. grimlockpdp

    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!!
     
  2. Rockn

    Rockn

    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.
     
  3. grimlockpdp

    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.
     
  4. Rockn

    Rockn

    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.
     
  5. grimlockpdp

    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.
     
  6. Rockn

    Rockn

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

    grimlockpdp Thread Starter

    Joined:
    Sep 22, 2009
    Messages:
    26
    Actually I used a subquery list and that worked. Thanks for the help though.
     
  8. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    No problem. More than one way to skin a cat.
     
  9. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1027382

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice