Free Trial

Alteryx Designer Desktop Discussions

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

Running Multiple SQL Queries

dineshbabu2811
8 - Asteroid

My workflow has many sql queries which needs to be executed based on the some conditions.

 

can we able to store the sql queries as text input and execute it as per need ? 

9 REPLIES 9
alexnajm
17 - Castor
17 - Castor

Have you checked out the Dynamic Input In-DB Tool | Alteryx Help?

dineshbabu2811
8 - Asteroid

Yes @alexnajm but I didn't get it

 

For example, I have 5 different set of SQL queries, which needs to be executed in different places depends upon the condition.

 

Column A - Condition/Reference

Column B - SQL Query

 

Trying to figure how to fix it

Robin_McIntosh
11 - Bolide

@dineshbabu2811 - What kind of conditions?  Conditions based on interface selections by the user?  or conditions based on previous tools within the workflow? For example, I have an app where the user selects 1 or more options (total of 8 different options) and then a formula tool creates a string that gets passed into a Dynamic Input tool by appending to the existing WHERE clause.  So depending on the different options selected, the additional WHERE clause string will change.  Same could be done based on upstream data/conditions within the workflow.

dineshbabu2811
8 - Asteroid

@Robin_McIntosh Conditions depends upon the previous workflow, for example particular ID will search number of units and it will perform the logic , then if it matches with other input it will generate output, if not need to pull extra data from some other table. If possible give me some simple example so that I'll develop it.

 

Also in the workflow, end user will enter the ID and password details to connect the database and we are not maintaining generic IDs. This is working perfect.

 

Robin_McIntosh
11 - Bolide

@dineshbabu2811 So I'm taking it something like this in terms of previous data in the workflow and you need to perform additional queries based on if the data meets the conditions.  Right?

ConditionSQL Query
IF Client = 'ABC'Select * From table A Where Client = 'A'
IF Amount > 1000Select * From table B Where Status = 'Closed'
IF State in('FL','GA','AL')Select * From table C Where Region = 'Southeast'
dineshbabu2811
8 - Asteroid

@Robin_McIntosh Yes something like this only

Robin_McIntosh
11 - Bolide

@dineshbabu2811 Here's a very rudimentary example without knowing your specifics.  Hopefully it gets you on the right path.  The different dynamic inputs contain the Select * From Table XX and then the configuration replaces the specific string "WHERE HERE" with the query (just the where piece) built in the formula tool.

Robin_McIntosh_0-1680113739790.png

 

dineshbabu2811
8 - Asteroid

@Robin_McIntosh This helped and sorted thanks so much, one more clarification here I have created macro to connect by database, where my user ID and password can be given as input values by end user.

 

Also can we able to give the entire sql query string as dynamic input and include conditions? like how we gave in the above one based on conditions? dineshbabu2811_0-1680115033731.png

dineshbabu2811_1-1680115269409.png

 

 

apathetichell
19 - Altair

as mentioned by @alexnajm this is best accomplished via dynamic input in-db in a batch macro. I do this. Every day. multiple times a day. 

 

Imagine the Drake meme. Imagine the words "Dynamic Input" in the top picture. Imagine the words "Dynamic Input In-DB" in the lower picture.

Labels
Top Solution Authors