aspose file tools*
The moose likes JDBC and the fly likes Multiple Values in single parameter marker Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Multiple Values in single parameter marker" Watch "Multiple Values in single parameter marker" New topic
Author

Multiple Values in single parameter marker

Java Dev
Greenhorn

Joined: Oct 20, 2003
Posts: 2
Hi all,
I am trying to find out the best way to insert multiple values into single parameter marker.
for example..
Let's say I want to run this SQL Query...
"SELECT * FROM EMPLOYEE WHERE EMP_ID IN ( 'ABC', 'ADD', 'AEE', ACG' );"
And I have this JAVA code...
PreparedStatement selectStmt = connection.prepareStatement( "SELECT * FROM EMPLOYEE WHERE EMP_ID IN (?)" );
selectStmt.clearParameters();
selectStmt.setXXXX( 1, MULTI_VALUES);
Is there a way to add multiple emp_id in above "IN" Conditional SQL Query in single parameter marker to run above query?
I know I can use setString to run "WHERE EMP_ID = ?" but I am having some trouble setting up for multiple IN values.
Or if not, what is the best way to deal with this issue.
Thank you very much.
Q
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Java Dev:
Is there a way to add multiple emp_id in above "IN" Conditional SQL Query in single parameter marker to run above query?
In general, no, there isn't, even though a few database drivers might allow it. You could dynamically generate SQL with the right number of question marks.
- Peter
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Java Dev
Welcome to Javaranch! We don't have too many rules but we do have a Naming Policy. Please review this policy and then change your display name to meet those requirements.
Thank you and we hope you enjoy Javaranch.


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Values in single parameter marker