aspose file tools
The moose likes JDBC and the fly likes How to pass values to a Oracle query with a IN clause Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "How to pass values to a Oracle query with a IN clause" Watch "How to pass values to a Oracle query with a IN clause" New topic
Author

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

Akshay Sharma
Ranch Hand

Joined: Mar 27, 2003
Posts: 42
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.


Akshay Kumar Sharma<br />**********************<br />Good Better Best <br />Never Let it rest<br />For your good is better<br />and the better is the best
Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 125
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 ]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: How to pass values to a Oracle query with a IN clause
 
Similar Threads
HELP:Can "Date" in java compare with "Date" in Foxpro?
HELP:Can "Date" in java compare with "Date" in Foxpro?
Efficient Method for comparison
Urgent : Help needed in writing a SQL query
ClassicQueryTranslatorFactory & Custom Functions Doesn't work?