Home > Ask the Data Management Experts > Questions & Answers > Help with the 'in' clause
Ask The Data Management Expert: Questions & Answers
EMAIL THIS

Help with the 'in' clause

Craig Mullins, Years 2005-2006 EXPERT RESPONSE FROM: Craig Mullins, Years 2005-2006

Pose a Question
Other Data Management Categories
Meet all Data Management Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 14 May 2003

In DB2 I have a query which goes like this:

Select * from mytable where where mark in ('a','b','c'............);

The 'in' clause is generated dynamically and the size of query size goes to 261 kb. an exception is thrown. It works if I make the size of the 'in' clause lesser.

I have made the Statement heap size to max, still it's not working. Do you have a solution?
Thanks in advance


>
EXPERT RESPONSE

This appears to be a question about DB2 on Linux, Unix, Windows (not OS/390), but let me attempt to give an answer. Some times SQL statements can become too large or too complex for DB2 to be able to handle them appropriately. This seems to be what is happening with this particularly query of yours.

You state that it "throws an exception" but you do not specify what that exception is. Is it a SQLCODE -101? If so, then your statement is just to long/complex for DB2 and you have to shorten it somehow. Perhaps you can insert the values to be check in the IN clause into another table. For example, insert the appropriate values into a column named vals in a table named marktable. Then you could write the SQL statement as:

select * from mytable where mark in(select vals from marktable);

Of course, this might not be as efficient, but it should avoid the -101 SQLCODE.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
IBM DB2
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 6
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 5
DB2 basics
IBM DB2 basics
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 4
DB2 looks to enterprise information management to fend off Microsoft
DB2 tools and products for Linux, UNIX and Windows: The basics
Understanding IBM DB2: Product history and strategy
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 3
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 2

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2005 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts