| | |
problem with lengthy query
![]() |
•
•
Join Date: Sep 2004
Posts: 2
Reputation:
Solved Threads: 0
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:
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
- Problem with Linq query (C#)
- Problem in inserting query in database (MySQL)
- Problem with MySQL Query (Database Design)
- Problem execute the Query (PHP)
- Problem regarding mysql query: it is displaying duplicate contents (MySQL)
- Query class problem (PHP)
- Problem with query. (MS SQL)
- query problem (MySQL)
Other Threads in the Java Forum
- Previous Thread: Printing in awt
- Next Thread: java price is right game help
| Thread Tools | Search this Thread |
-xlint actionlistener add android applet application array automation bank bi binary blackberry block bluetooth character class client code compile compiler component consumer database desktop developmenthelp eclipse equation error event fractal ftp functiontesting game gameprogramming givemetehcodez graphics gui health html hyper idea image infinite int j2me j2seprojects java javac javaee javame javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux mac main method mobile myregfun netbeans notdisplaying number online pearl printf problem program qt researchinmotion rotatetext rsa scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows xor





