Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
kaushi2020
Creator II
Creator II

Call a Procedure when the select statement matches a criteria

Hi All, 

we have an ETL process where we record steps for each execution. 

I am trying to call a procedure via load editor if the select criteria matches.

Example:

If 

Select Step from table1 where Step=12

and Date=Current_date;

then

Call Procedure();

 

Exit Script;

 

Is this possible to achieve this logic ? 

thanks in advance.

Labels (5)
1 Solution

Accepted Solutions
Or
MVP
MVP

Assuming you've enabled non-select statements as per https://help.qlik.com/en-US/connectors/Subsystems/ODBC_connector_help/Content/Connectors_ODBC/How-to... - yes.

You would load whatever you're checking, use NoOfRows() or Peek() to check if any records were returned, and then based on that you would switch the IF statement logic,e.g.

Table1:

Select Something from Somewhere;

IF NoOfRows('Table1') >= 1 THEN

Do something

End if

 

View solution in original post

3 Replies
Or
MVP
MVP

Assuming you've enabled non-select statements as per https://help.qlik.com/en-US/connectors/Subsystems/ODBC_connector_help/Content/Connectors_ODBC/How-to... - yes.

You would load whatever you're checking, use NoOfRows() or Peek() to check if any records were returned, and then based on that you would switch the IF statement logic,e.g.

Table1:

Select Something from Somewhere;

IF NoOfRows('Table1') >= 1 THEN

Do something

End if

 

kaushi2020
Creator II
Creator II
Author

Thanks a lot for your suggestion, it worked. 

However we need to check if this procedure has ran already or if this will be the first time it is executing based on the condition where it checked for NoOfRows >=1.

 Below is the scenario what i am assuming.

If Step reached --> Run Procedure;  // Running PROCEDURE for the first time.

If not reached --> no action

If Step reached--> Procedure already ran once --> Do Nothing.

 

Please suggest if above condition can be added as well ? 

Or
MVP
MVP

Set RunStatus=0;

IF RunStatus = 0 and ...

Then

Call Procedure

Set RunStatus = 1;

End if

 

Note that this will only check if you've attempted to run the procedure. If you want to know if the procedure actually did something / finished running, you would need to handle that on the data source side and then load the result.