Skip to Content

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.

Job.jpg

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

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

Print(‘Rows’||$RC);

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’);

If.jpg

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)

Value.jpg

observe Trace and Error logs.

Hope it helps somebody need.

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. DILIP KUMAR

    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.

    (0) 
    1. Sateesh Kumar Post author

      Hi Dilip ,

      Make sure you are passing correct values for the parameters and has set condition properly .
      If you still have issues , share screenshots to observe issue.

      Thanks

      (0) 
  2. Varaprasad Yagante

    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

    (0) 
  3. DILIP KUMAR

    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

     

    (0) 

Leave a Reply