Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi there,
I have one question related to global variables in DSS. Namely, is it possible to define a list as global variable and then use this in an SQL statement? What I am thinking of is something like this:
Global variable:
{"test_list": ["A", "B"]}
SQL Statement
SELECT *
FROM test
WHERE "test_col" IN ('${test_list}')
Thanks a lot for your help!
Best,
Oliver
Hi,
You query
SELECT *
FROM test
WHERE "test_col" IN ('${test_list}')
will be executed as
SELECT *
FROM test
WHERE "test_col" IN ('["A","B"]')
Then you need to cast this string to an array, and the how depends on your SQL database.
EDIT: here is an example for PostgreSQL using the jsonb type and the ? operator.
SELECT *
FROM test
WHERE '${test_list}'::jsonb ? "test_col";