Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Coming Aug. 9: New Simplified Authoring for Qlik Sense SaaS – For Details, CLICK HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
crissaegrim
Contributor III
Contributor III

In a reload script and reload task, raise exception if "0 lines fetched"

Hi.  How can I raise an exception if I have a "0 lines fetched" during any point in the reload task?

2016-11-30 08:00:06 0104 FROM [myDatabase].[dbo].[myTransactionsTable]

2016-11-30 08:00:06 0105 WHERE TranType IN (

2016-11-30 08:00:06 0106 'buy'

2016-11-30 08:00:06 0107 ,'sell'

2016-11-30 08:00:06 0108 )

2016-11-30 08:00:06 0109 AND InvCode NOT LIKE '%collateral%'

2016-11-30 08:00:06 0110

2016-11-30 08:00:06 0111 ORDER BY TDate DESC

2016-11-30 08:00:07      30 fields found: *** OMITTED FOR BREVITY ***

2016-11-30 08:00:07      0 lines fetched

1 Solution

Accepted Solutions
rwunderlich

The only way to raise an exception is to introduce an intentional syntax error like this:

IF NoOfRows('TableName')=0 THEN

    Failing due to no rows;

ENDIF

The "Failing due to no rows" is an invalid statement, but it will nicely show as the error cause as well.

-Rob

View solution in original post

5 Replies
rubenmarin

Hi Khoa, the function NoOfRows('TableName') returns the number of rows, you can check if it's equal to zero.

crissaegrim
Contributor III
Contributor III
Author

How do I then raise an exception?  Thus marking reload task as failure?

rubenmarin

Hi Khoa, you can finish the reload with "Exit Script;" Is this what you want?

You can use it like:

Exit script when NoOfRows('TableName')=0

or:

IF NoOfRows('TableName')=0 THEN

Exit Script;

ENDIF

crissaegrim
Contributor III
Contributor III
Author

Would Exit Script; cause the task to end in failure in QMC?  Because this is what I want.  I need an easy way to, at a glance, tell fail from success of my tasks.

rwunderlich

The only way to raise an exception is to introduce an intentional syntax error like this:

IF NoOfRows('TableName')=0 THEN

    Failing due to no rows;

ENDIF

The "Failing due to no rows" is an invalid statement, but it will nicely show as the error cause as well.

-Rob