Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Partner Ambassador/MVP
Partner Ambassador/MVP

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.

Anonymous
Not applicable
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

Anonymous
Not applicable
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
Partner Ambassador/MVP
Partner Ambassador/MVP

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