- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 08:10 AM
In a Discovery Pattern, how can I check if a Table has 0 results?
Steps:
1) Parse a file and store the results in a Table. Se
2) Use a Match operation to check if an array/table has 0 results. Stop execution of the pattern extension if there are no results.
I tried this, but it does not work as expected. Only if the
Operation: Match
$_rnr_scheduled_tasks_ is Empty
I've also tried:
$_rnr_scheduled_tasks_[] is Empty
and
$_rnr_scheduled_tasks_[*] is Empty
None of these conditions cause the Pattern to gracefully exit. Any idea on how to proceed?
Solved! Go to Solution.
- Labels:
-
Discovery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 07:50 AM
Oh, alright, my bad, i sometimes am a bit slow.
I never had to do that before, but my guess is, that you could check for the first line in your table to be present. Could you check if
$_rnr_scheduled_tasks_[1]."some_column" is Empty
works? Ideally use a column that is always filled. The issue here is, that - as far as i understand patterns - the "isEmpty" only checks for the string based value of a variable. This means any table with columns - no matter if they have an value - is no longer empty (this at least is my interpretation of why it may not work in your case).
Also sorry for my daylong wait, i don't get notifications in time by the community at the moment...
Regards
Fabian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 12:45 AM
Hey,
Just to make sure this is not the usual hickup, which happens to me a lot:
With the match operation you are matching if a pattern should continue. In your case the pattern continues, if the table is empty.
However, as i understand it, you want the pattern to terminate, if the tasks are empty. Please try to invert your check for this case (is not Empty).
Regards
Fabian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 08:54 AM
Thanks for your reply, but I've tested with Termination Type = Expected and Not Expected to no avail. None get triggered on any of these conditions:
- $_rnr_scheduled_tasks_ is Empty
- $_rnr_scheduled_tasks_[] is Empty
- $_rnr_scheduled_tasks_[*] is Empty
Also, I've tested and can confirm that both Termination types will stop the flow of the pattern. In my view:
- Termination Type = Not expected equates to a catastrophic failure. e.g. something isn't right and sys admins should have a look
- Termination Type = Expected equates graceful termination. e.g. No records to process, so exiting. Nothing to to do here, and sys admins need not to be concerned.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 11:09 AM
Hi,
Yes, thats because the pattern is supposed to continue if the condition is matched. What your condition should look like is:
- $_rnr_scheduled_tasks_ is NOT Empty
- $_rnr_scheduled_tasks_[] is NOT Empty
- $_rnr_scheduled_tasks_[*] is NOT Empty
The Termination Type just tells the system wether or not the pattern has run into an error state. If you use the "Expected" termination type the rest of the pattern sections will be executed. "Not Expected" will throw an error and stop the discovery process.
Hope this clarifies it a bit. I might also just have a brain-lag here and not fully understand the issue.
Regards
Fabian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2022 06:51 AM
Thanks Fabian.
Putting the Termination type aside, the question is with regards to how to detect a table with no data - 0 rows. The pattern can detect an empty variable altogether with $_rnr_scheduled_tasks_ is Empty, but I cant seem to detect if the the variable exists, but with no data. This is occurs in my pattern after removing some rows with a filter, so I want to see if there are any rows remaining after a filter operation and stop the execution of the pattern (or one step of a pattern with pre-condition). This is super simple in any language, but I can't seem to do it with the pattern. Worst case, I might have to resort to a Eval() operation to detect a table with no rows left in it.