Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass values to a Oracle query with a IN clause

 
Akshay Sharma
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SELECT * FROM test WHERE a IN ('0515','0514','0516')

In java
SELECT * FROM test WHERE a IN (?)

String temp = "'0515','0514','0516'";
pstmt.setString (1,temp);
This does not work.
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

May be the String that you are setting to the prepared statement would be treated as one String arguement..so the final Query would look like

SELECT * FROM test WHERE a IN (' '0515','0514','0516' '); // Note the Quotes

I dont know if this should actually result in an SQLException.

try using

SELECT * FROM test WHERE a IN (?,?,?); and then set the each Parameter...this might help.
[ December 23, 2004: Message edited by: RajaniKanth Bhargava ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic