0

I am unable to send the String[] or List as an args to the "IN" operator. Can you please suggest me how to send the an input value for IN operator using crate java client.

1 Answers1

1

it depends on what you are trying to achieve, IN only takes arbitrary length function parameters, which (assuming you want to use the '?' parameter substitution) does not take any array/list/other collection, but single values: For example select * from information_schema.tables where schema_name in (?, ?, ?); would be translated into select * from information_schema.tables where schema_name in ('a', 'doc', 'b'); when the parameters were ['a', 'doc', 'b']. See also: https://crate.io/docs/reference/sql/queries.html#in

If you want to check if a value was is an array, ANY() could work for you: https://crate.io/docs/reference/sql/queries.html#any-array - it should take an array as parameter.

Hope that helps!

Claus

claus
  • 377
  • 2
  • 9
  • here is my query with "IN" select * from users where (id IN (?)) Object[] args = new Object[]{"'1','2','3',......."}; this did not work either from java client. Also is there any limitation on this input size for IN? – Anil Kandacharam Feb 26 '16 at 09:55
  • you can use `select * from users where id = ANY (?)` and `args = new Object[] { new Object[] { "1", "2", ... }}`. – mfussenegger Feb 26 '16 at 10:45