How to parameterize the DB Row Filter with flow variables (WHERE-IN clause)

Could someone help me with the following problem?

I want to parameterize the DB Row Filter with flow variables. To get familiar with the flow variable configuration I would like to consider a very simple case. The DB Row Filter shall perform the following task: Search in a column ‘Source ID’ for the entries ‘1000001234’ and ‘1000001235’. So, behind the scenes the knot should do the following:

SELECT * FROM my_table_name
WHERE SourceID IN (‘1000001234’, ‘1000001235’).

My flow variable tab looks like this.

DB Row Filter Parameterization with Flow Variables.pdf (16.5 KB)

How do I have to set up the parameters?

Thanks a lot for your support!

Heiko

1 Like

Hey there and welcome to the forum!

Good question and to start with I felt it was not too straight forward.

The trick is that you need a flow variable that has the options you want to select as a string with each value inside single tick quotation marks:
e.g. myVar:

'Option1', 'Option2'

If you have that variable, you can pass it into your query:

Select * from...
WHERE "columnToTest" IN ($${SmyVar}$$)

See here:

Example in the red box… I grab first two rows from a data set as an example
Then use Expression Node to put quotation marks around the target column
Then use Group by to aggregate that column using unique concatenate as aggregation function
Then turn that into a variable and pass that variable into DB Query node:

SELECT * FROM #table# AS "table"
WHERE "Gene stable ID" IN ($${SGene stable ID}$$)

Workflow
DB_WHERE_IN.knwf (101.4 KB)

3 Likes

In addition to Martin:
If you want to use the „WHERE IN“ SQL clause only, you can use the DB LOOPING node.

3 Likes

Hi Martin and Andi,

many thanks for your support! I wasn’t aware that there is also DB Query knot which I took now and which is way easier to parametrize! So, my workflow is running as desired. Have a nice remaining day!

Heiko

Great!
Please mark Martins or my answer as solution. So its easier to find

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.