problem with lengthy query

Reply

Join Date: Sep 2004
Posts: 2
Reputation: ranyodh is an unknown quantity at this point 
Solved Threads: 0
ranyodh ranyodh is offline Offline
Newbie Poster

problem with lengthy query

 
0
  #1
Sep 3rd, 2004
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:
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC