944,165 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2416
  • Java RSS
Sep 3rd, 2004
0

problem with lengthy query

Expand Post »
hi to everyone....

I got a problem with queries.... before i tell my problem, please look at the is code -


// employeeCode is ArrayList containing employee codes.

String query = "SELECT Name, FatherName from Employee WHERE ";
for(int i=0; i<employeeCode.size(); i++) {
if(i == 0) {
query += " (EmployeeCode = "+Integer.parseInt((String)
employeeCode.get(i));
} else {
query += OR EmployeeCode = "+Integer.parseInt((String)
employeeCode.get(i));
}
}
query += ")";


Now, this code generate query somewhat like this -
"SELECT Name FatherName FROM Employee WHERE (EmployeeCode = 1 OR EmployeeCode = 2 OR EmployeeCode = 3 ......(and so on)"

My problem is that, employeeCode may have 1000's codes. and this query will become quite lengthy. Can Database engine handle such a long query. I know at some point, it give error message saying "Query is too complex".



I use jdbcodbc database engine.

can you suggest some ohter way.
:rolleyes:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ranyodh is offline Offline
2 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Printing in awt
Next Thread in Java Forum Timeline: java price is right game help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC