IBM Information Server - call job variable in another job

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Chandrathdsx
Participant
Posts: 59
Joined: Sat Jul 05, 2008 11:32 am

IBM Information Server - call job variable in another job

Post by Chandrathdsx »

Hello,

I have a job-A that does count(*) into a variable cnt from a table and this cnt is written into a dataset. I have two other jobs job-B and job-C, I want to run the job-B if the cnt is 0 otherwise run job-C (i.e., cnt > 0).

How to set this up in the job sequence? Is there any way to recoginize the job variable/field in the job sequence? Any detailed information is highly appreciated. Examples most welcome...

thank you!
Chandu.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Difficult if you're using a Data Set to store the intermediate result; you'd have to use an orchadmin command via an Execute Command activity to retrieve the result. Since it's only a single row, I'd advocate using a server job and posting the count into that job's user status area, whence it can be retrieved using the Job actvity's $UserStatus activity variable and that used in the downstream Nested Condition activity.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

You can use the execute stage or the Variables stage call an external SQL script that retrieves the value directly from the database and the output trigger or the condition stage reads the value returned and decides on which path to take. Or you can write the count to a sequential file and use a Sequential job routine stage to open the file and return the value. For storing such a small amount of data a dataset is overkill and hard to access outside of a parallel job.
Chandrathdsx
Participant
Posts: 59
Joined: Sat Jul 05, 2008 11:32 am

Post by Chandrathdsx »

vmcburney wrote:You can use the execute stage or the Variables stage call an external SQL script that retrieves the value directly from the database and the output trigger or the condition stage reads the value returned and decides on which path to take. Or you can write the count to a sequential file and use a Sequential job routine stage to open the file and return the value. For storing such a small amount of data a dataset is overkill and hard to access outside of a parallel job.
Hello,

Thanks for the reply.. I tried with storing the count(*) from the table into a seqential file. In the job seq I am doing a routine EXEC Command to check if the dataset is empty (using wc -l) and trigger link1 if the file is not empty trigger link2. I tried the conditional trigger using the returnvalue [=0 for link1 and > 0 for link2] despite whether the file is empty or not always link1 is getting executed. Then I tried the trigger based on commandoutput [=0 link1, > 0 link2, here always the link2 is getting execuded despite if the file is empty or not. Can anyone please help me how to check the file is empty or not and trigger link1 if the file is empty, if the file is not empty trigger link2. any help is highly appreciated. Thank you!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Are you sure your empty file is actually empty, i.e. it doesn't have a header record? You'll need to remove any Field Marks in the output of the Execute Command stage before the number will compare correctly:

Code: Select all

Convert(@FM,"",CommandOutput)
-craig

"You can never have too many knives" -- Logan Nine Fingers
Chandrathdsx
Participant
Posts: 59
Joined: Sat Jul 05, 2008 11:32 am

Post by Chandrathdsx »

chulett wrote:Are you sure your empty file is actually empty, i.e. it doesn't have a header record? You'll need to remove any Field Marks in the output of the Execute Command stage before the number will com ...
Yes.. My empty file is empty.. I was running the WC - L < 'file name' under unix and it is returning 0. when I have data in the file I am getting the wc - l < 'filename>' value as 1. But, still the costum condition with CommandOutput = 0 does not trigger the empty file link.

Trigger conditions:
Expression type: Costom. Expression: CommandOutput > 0 [to trigger Data_exist link]
Expression type: Costom. Expression: CommandOutput = 0 [to trigger No_Data link]

Here is the output of the Director log:
EMPTY FILE DIRECTOR LOG:
seq_cond_tst1..JobControl (@Execute_Command_39): Executed: wc -l < /development/load_dir/Rath_tst.txt
Reply=0
Output from command ====>
0

FILE HAS DATA DIRECTOR LOG
seq_cond_tst1..JobControl (@Execute_Command_39): Executed: wc -l < /development/load_dir/Rath_tst.txt
Reply=0
Output from command ====>
1


ANY HELP IS HIGHLY APPRECIATED AS I NEED A RESOLUTION FOR THIS ASAP..
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As noted, you need to remove any hidden Field Marks from the returned value before the number will compare properly. Use Convert to strip them from the output.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Chandrathdsx
Participant
Posts: 59
Joined: Sat Jul 05, 2008 11:32 am

Post by Chandrathdsx »

chulett wrote:As noted, you need to remove any hidden Field Marks from the returned value before the number will compare properly. Use Convert to strip them from the output. ...
chulett, Thanks for the help. I added coversion to strip everything except the first digit, it worked as I expected. As you mentioned the hidden field mark was the problem.

Thanks again!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Cool... please mark the topic as Resolved then.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply