1

I have function in Snowflake where I would like to input a variable there contains a IN statment for a query.

It works when I only have one item:

select * from table(my_function('62696'))

But I can not figure out how to do when I have more items, I have tried different ways like:

select * from table(my_function(''62696','62695''))
select * from table(my_function('\'62696\',\'62695\''))

But no of them does work.

jvels
  • 319
  • 2
  • 16
  • Or alternative if it is possible to input JSON and then "unpack" JSON so it fit into a IN () statment – jvels Oct 03 '21 at 06:45

1 Answers1

1

I did solve it with by call the function with:

select * from table(my_function('62696,62695'))

In the function I use it like this:

IN (SELECT VALUE FROM TABLE(SPLIT_TO_TABLE(MY_INPUT, ',')))
jvels
  • 319
  • 2
  • 16