We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Passing workflow constant to SQL Query - using IN condition for multiple items

terrence10
8 - Asteroid

I am passing workflow constants in my SQL query input tool like below:

 

 WFConstant1.png

 

I want to be able to query multiple items - e.g Strategy in ('Forwards', 'Down200')

 

When I enter in my workflow constants like this with single quotes, the query errors because the quotes - it looks like Alteryx adds a single quote around the whole input string - and SQL cannot interpret this

WFConstant2.png

Log:

WFConstant3.png

 

 

If I submit my inputs without the single quote, the query completes, but no records are returned:

WFConstant4.png

Log:

WFConstant5.png

 

The query works if I only pass one value - e.g. Down200 with no quotes.

 

I want to be able to pass one value as a constant - e.g. ('Down200') or two values ('Down200', 'Forwards')

 

How do I structure my SQL query input tool and/or Workflow inputs in order to query multiple items in an IN condition?

 

Thanks!

 

6 REPLIES 6
davidskaife
14 - Magnetar

Hi @terrence10 

 

I know its not the ideal solution but could you not enter Down200', 'Forwards as a temporary measure?

 

Also found this which may be of use - https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Passing-the-workflow-constant-...

terrence10
8 - Asteroid

Thanks @davidskaife !

Not ideal to have the user format the input as Down200', 'Forwards when running the workflow - but it works!

 

I think the situations where we would run multiple inputs will be rare so I've accepted this solution for now. This is good to know that if we follow this input syntax - we will be able to run multiple inputs

 

Thank you!

WFConstant6.png

davidskaife
14 - Magnetar

You're welcome. Yeah it's not ideal from a users perspective!

 

A query - are you providing this to the user as an App on the Gallery? Rather than using constants could you not use the Interface tools to fill out the required inputs, that may be a better workaround?

terrence10
8 - Asteroid

I am running this workflow in both places - sometimes in App, sometimes in Gallery.

 

Not too sure which interface tools might work for this case @DavidSk  ? 

You mean like maybe have an action tool that intakes 'Down200', 'Forwards' and replaces this in a query?

 

Thanks again!

   

 

 

davidskaife
14 - Magnetar

Hi @terrence10 

 

Something like that yeah. As an example using a Text Box tool you could ask the user to enter Down200 and Forwards and the Action tool will update the query - take a look at the Dynamic Input tool, if you're not already, as that has a section for modifying SQL.

 

It would likely take a bit of trial and error to get it working correctly.

terrence10
8 - Asteroid

Got it, thanks! I haven't used the Dynamic input tool much, so will give that a try - to "Modify SQLQuery" with this tool

 

Thanks again!

Labels
Top Solution Authors