Using Prepared Statement to pass array of primary key
How can i use the PreparedStatement to send the array (It can be variable depend upon the user selection) of primary keys to database
For example I want prepare statement somthing like this
public Collection findByIds(long[] ids){
String sql = "select * from Person where person_id IN (?)"
PreparedStatement ps = conn.prepareStatement(sql)
ps.setArray();
//
//
//
}
Any example this regard will be appreciated. Database is Oracle
[504 byte] By [
sohailn] at [2007-9-26 1:14:21]

Hi!
I found your question about sending an Array to a SQL phrase.
(http://forum.java.sun.com/thread.jsp?forum=48&thread=150061)
I have found the same problem.
If you have resolved that problem more elegant than build a SQL phrase dinamic please send me an email with your solution at danctanase@yahoo.com .
Example :
I try to send a parameter to a phrase like this
select * from tableName where fieldName in ?
where ? is like [ "a", "b", "c"] - this collection may have different number of elements.
I don't want to create a SQL phrase dinamic (it's ugly) like this
select from tableName where fieldName = "a" or fieldName = "b" or fieldName = "c"