• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

in clause issue

 
M Ryder
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to query a database with selections from a jsp form to create a report. I am pulling the selections into a servlet, adding delimiters and then using in a where clause, but I can't seem to get the syntax right (I think i have been staring at it to long). instead of getting ('1','2','3') I am getting ('1,2,3,') so it is not working. Any suggestions would be greatly appreciated.

getting parameters from jsp;

adding delimiter;

where in clause:

[ May 16, 2008: Message edited by: Scott Selikoff ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need the quotes around each value. Meaning the piece of code where you add the delimiter needs to handle quotes as well as the comma.

StringBuffer agreeb = new StringBuffer();
for(int i = 0;i < dbAgree.length; i++){
agreeb.append(dbAgree[i] + ","); }
String agree = agreeb.toString();
agree = agree.substring(0, agree.length()-1);
 
M Ryder
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne. Still can't get it to work, now I get to many quotes
('1','2','',') something is not right, I will keep on trying.
 
M Ryder
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,
I have modified my code below and it still doesn't fix the issue. Any other suggestions?
 
Chad Naber
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that you added two more characters, you need to modify the substring:

agree = agree.substring(0, agree.length()-3);
 
M Ryder
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chad, sometimes a second pair of eyes will do the trick
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic