Implementing If/Then

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
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

raggid

"If/then/else" can return 2 values. You can trick it into doing an "elseif" by concatenating an empty string to the else. Try:

If x=1 then 1 else "": if x=2 then 2 else "":if @true then 3

Kim.

Kim Duke
DsWebMon - Monitor DataStage over the web
www.Duke-Consulting.com
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

raggid

Sorry I misunderstood the question. If a source file is empty then the job will finish just process no rows. You could do it in a routine. I posted the code yesterday to get the length of a sequential file. Just use that in a constraint.

Kim.


Kim Duke
DsWebMon - Monitor DataStage over the web
www.Duke-Consulting.com
gpbarsky
Participant
Posts: 160
Joined: Tue May 06, 2003 8:20 pm
Location: Argentina

Post by gpbarsky »

Kim:

Could you specify me where did you post the code for checking the length of a sequential file ?

Thanks.


Guillermo P. Barsky
Buenos Aires - Argentina
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

http://www.tools4datastage.com/forum/to ... C_ID=85322

I believe this is the link for finding file size posted by Kim Duke.


thanks
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

raggid

Each output link has a constraint. A constraint has to be true if any records are to written.

Here is the code that you need to build around a routine but you just stated that these are hash files.

file = "KDBPOpenSeqSize.uvb"
openseq file to SeqFile else stop
status FileInfo from SeqFile else stop
FileSize = FileInfo
print FileSize

Hash files would be different. Your issue can be solved easier than I thought.

Job 1 has a before routine which writes a "0" into a hash file. Create a hash file with one record then update this record if any rows are written in this job. Have a constraint with if @OUTROWNUM = 1 so only one row gets written. Make the key = "Results".

Job1:
hash1 -> transform -> normal output1
. -> output2 HashResults, "Results"

If no rows are in hash1 then HashResults, "Results" has a "0 in it.

The next job will need to lookup HashResults, "Results" and if there is a "0" then do not output anything.

Job2:
hash2 ->
HashResults, "Results" -> transform -> normal output1

Routine1:


open "HashResults" to HashResults then
Opened = @true
end else
Cmd = "CREATE.FILE HashResults DYNAMIC"
execute Cmd capturing output
open "HashResults" to HashResults then
Opened = @true
end else
Opened = @false
end
end
if Opened then
write "0" on HashResults, "Results" else Opened = @false
end
Ans = Opened
.
.
.



This should get you close.

Kim.


Kim Duke
DsWebMon - Monitor DataStage over the web
www.Duke-Consulting.com
Post Reply