Skip to Content

Conditional execution of a job

Hi Team,

It’s a basic requirement but most common .So I wanted to share it for beginners.

Purpose : Job should execute for a selected country .If there are no records for the selected country then job should terminate .

Create 2 global variables to at Job level

$CNTR : Country to select when job execution

$RC : count records for selected country.


1.Scr_Records : to count the records for a selected country.

$RC = sql(‘SRT’,’SELECT Count(*) FROM Stadium_Info where COUNTRY={$CNTR}’);


2.Add try and Catch to display the error message in Trace log

3.Add Conditional (If) transformation .

        In Condition part , write $RC >0

        * Then part : Create your dataflow when condition met .Put Stadium_Info.COUNTRY =$CNTR in transformation WHERE clause to restrict rows for selected country.

        *Else part  : Create a script to generate error

         Scr_Raise_Exception :  raise_exception( ‘Table is Empty’);


4. In Catch block :

Add a script  to Print your error message in Error log

raise_exception( ‘There arer no records to fetch for ‘||$CNTR);

5.Execute the job and enter value for Country variable $CNTR =’IN’ ( in database there are no records for IN)


observe Trace and Error logs.

Hope it helps somebody need.

You must be Logged on to comment or reply to a post.
  • hii satesh kumar

    Good explanation,tryed same thing which you mentioned but getting error.

    Having record but The error is showing there are no records to fetch for.

  • how to check exceptions ? if no exceptions update the final table as “job is successful” else “job is failed” ¬†, i am trying to use conditional if after try block, but its throwing me syntax error

  • HI Have been trying to post my dought but not able to get submit comment button.

    My requirement is

    While extracting data from flat files,after processing flat files should move to sucess folder those files are processed successfully and failure files¬† move to failure folder as well as if file doesn’t contain single row that kind of file should move to separate folder.

    Plz help me….hae been looking blogs ut didn’t get proper information

    Thanks in advance