0

I use variable binding in ORACLE with java/groovy like these:

String sql = "SELECT * FROM myTable WHERE id = :id"
sqlConnection.query(sql, [id: 111])

It works perfect. But when I try the same with an IN-keyword I got an error:

String sql = "SELECT * FROM myTable WHERE id IN(:ids)"
sqlConnection.query(sql, [ids: [111, 222, 333]])

When I execute it I got this error: java.sql.SQLException: Invalid column type

Has anybody an idea?

Steffen S
  • 17
  • 1
  • 5
  • 1
    You can replace `sqlConnection.query(sql, [ids: [111, 222, 333]])` With `List ids = Arrays.asList(111, 222, 333)` `sqlConnection.query(sql, [ids: ids])` – Tushar Mar 23 '23 at 17:03
  • Please let me know, if you still face any problems – Tushar Mar 23 '23 at 17:03

1 Answers1

0

It won't work like that. It is possible only if you have a bind variable fore each of the members of the list. An alternative would be not to use a bind variable at all in case of the in list, but just pass the whole list as a string to Oracle.