Toad World® Forums

Empty data in xslx and IF activity?


#1

Hello,

Can you please help me build an automation using IF activity?

I have a basic sql query and export result set to email, automation. But we have cases when the exported excel file is empty since there is no data for that day.

What I would like is to have two sets of email messages. One which will be sent when there is data in the file and the other which will be sent when there is no data in the excel file (different body text).

How could I accomplish that?

Thank you.


#2

Hello,

I think that in your case easiest way would be use RowCount variable.

There are list of activities for your sample:

  1. Select to File - setup your SQL and Export file. In same activity you can see RowCount variable name: File_1_RCOUNT (you can rename it as you want).
  2. If…Condition… - create 2 conditions. When you click on condition you can set Expression
    1. #File_1_RCOUNT# > 0 -> Inside of this condition will be your email with attach report.
    2. #File_1_RCOUNT# = 0 -> Inside of this condition you can create email with empty body warning.

And thats it. Now you should be able get correct email base on your SQL result. I believe it is much more easier then create some comparing of file size.

Filip


#3

This is awesome Filip! Thank you very much. Such a simple solution. :slight_smile: