Skip to main content
Solved

Post-job event to send email if job finishes 0 rows

  • July 30, 2024
  • 4 replies
  • 139 views

Forum|alt.badge.img

I’d like to get information if certain job finishes successfully, but 0 rows are replicated. I found snippet that send email, but how can I write an “if query” that catches only  those scheduled jobs that I want? There is snippet template for that, but I don’t understand how it need to be modified

 


<!-- Enumerate Through Query Results -->
<api:enum prefix="Query#">
<api:set attr="temp.index" value="[_index]" />
<api:set attr="temp.query" value="[_value]" />
<api:set attr="temp.status" value="[QueryStatus#[_index]]" />
</api:enum>

 

 

Best answer by DougN Nouria

Even better, set that threshold for load volume at the Task level.  Some tables might be OK to have 0 rows replicated.  But other tables in the job, you might normally and always have 100K rows, so loading 0 would be atypical.

This topic has been closed for replies.

4 replies

Forum|alt.badge.img+1

Oooh, that would be a nice feature to add, under the Notification section.  A checkbox for “send email if 0 rows loaded into destination”.


Forum|alt.badge.img+1
  • Influencer
  • Answer
  • July 30, 2024

Even better, set that threshold for load volume at the Task level.  Some tables might be OK to have 0 rows replicated.  But other tables in the job, you might normally and always have 100K rows, so loading 0 would be atypical.


Forum|alt.badge.img
  • Author
  • Collaborator
  • August 27, 2024
<api:if exp="[AffectedRows] == 0">
<api:set attr="mail.Subject" value="Post-Event Mail"/>
<api:set attr="mail.Message" value="[JobName] : [JobStatus] : [AffectedRows] : [RunStartDate]"/>
<api:set attr="mail.To" value= "[email protected]"/>
<api:call op="appSendEmail" in="mail"/>
</api:if>

This is the working script for this purpose

 

 

 


Forum|alt.badge.img
  • Author
  • Collaborator
  • August 27, 2024