(In reply to this topic, as I think it belongs in the Data Access forum rather than the Core Container one.)
Henry,
Since you're using Oracle, you could create a collection type:
Then you can use a sql string like this:Code:CREATE TYPE ct_number AS TABLE OF NUMBER;
Declare an array parameter for the query:Code:SELECT ename FROM emp WHERE empno IN (SELECT column_value FROM TABLE (CAST (? AS ct_number)))
And use an Oracle-specific SqlTypeValue implementation:Code:declareParameter(new SqlParameter(Types.ARRAY, "SCOTT.CT_NUMBER"));
You'll probably need to configure a NativeJdbcExtractor on the JdbcTemplate used by the SqlQuery object.Code:final int[] value = new int[]{120,121}; query.execute(new Object[]{new AbstractSqlTypeValue(){ protected Object createTypeValue(Connection con, int sqlType, String typeName) throws SQLException { return new ARRAY(ArrayDescriptor.createDescriptor(typeName, con), con, value); } }});
Note that I haven't tried this code, but I've done something similar before. I suppose it's also possible to use more complex object types, like you'd need for the query in your first example.
Kind regards,
Tom.


Reply With Quote