Alteryx Designer Desktop Discussions

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

Error Handling for SQL Query

SamSurya
8 - Asteroid

Hi,

 

I have a query related to error handling: In my workflow, I'm extracting data from SQL table based on conditions and then consolidating output from each query with the help of union. Now the problem is if one query ends up with no data than my union gets fail. Is there a way that I can check that if records available only then Union gets data.

 

In the below image data from each join tool is going to Union tool.

 

SamSurya_0-1609162597564.png

 

3 REPLIES 3
BrandonB
Alteryx
Alteryx

It looks like your Data Stream out tools are receiving the errors which is your issue. It is possible to return 0 records from a query so it looks like the issue is with the query itself

 

no results.png

 

Can you provide more information about what is failing in your query?

SamSurya
8 - Asteroid

actually you have pointed it right... my apologies!!. So the problem is :

 

I have a SQL query having a where clause which checks if a field in table is null and name of the fields gets updated from a field. so If the field is not null a sql query will not get generated and thus there its shows up error. I would like to explain my problem with an example: I have a table Employee, and it has got columns as Employee_Name, Department, Manager, Role, Tenure. Now first task is to check separately if a column has null values. If yes then I need to fetch all the records  from the table which has null value. (Constraint here is the data is too huge and I can not get complete dataset extracted in one go as it takes hours). I have to hit database separately for each column because I m not able to pass list of sql queries to fetch data.

It is like below:

Column NameSQL
Employee_NameSelect * from Employee where Employee_Name is null
DepartmentSelect * from Employee where Department is null
ManagerSelect * from Employee where Manager is null
RoleSelect * from Employee where Role is null
TenureSelect * from Employee where Tenure is null

 

Please advise how can I achieve this, I do not know about macros in alteryx but think that can help or else if there's a way I can get all column names transpose in one line and then build a query using "Or" . please note here I have a huge data set and there can be a situation that for one particular month I have nulls in one column only then alteryx should create only one query.

 

would really appreciate your help on this. 

BrandonB
Alteryx
Alteryx

Are you checking to see if an entire column is null in the data? Is there a primary key that you link the Employee names/departments/etc back to?

 

I'm not entirely clear on what dictates whether or not the tables get looked up based on, but you will definitely want to leverage as much of the In-DB capabilities as you can for this use case. You may even find that you can use a Data Stream In tool to send your data up to a temporary table which can then be joined to other tables in your database so the entire logic and joining process is done In-DB. 

Labels