What is divide by zero rule.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

tanaya.deshpande@tieto.co wrote:I am calculating a column like this

Column A = (Column B+Column C)/Column D

Now if suppose a zero value comes at Column D then the Datastage will through an exception ..or an error so how can I handle this..

????
Standard approach: Insert If condition before doing calculation that defaults Column A = 0 (or any other branch action you wish) if Column D = 0. This will prevent divide by zero.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In other words, check first and only perform the division when the divisor is not zero.
-craig

"You can never have too many knives" -- Logan Nine Fingers
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

After further thought, it occured to me that this issue should start in the requirements. Any amount that is intended to be used as a denominator should have error handling for zero before it gets to the calculation. In COBOL, this is a standard item for an entire paragraph that does nothing but validate fields. Dates are also handled there, along with any more specific constraints on the data (not more than x days old, etc.)

In DS, I'd probably look first at either a filter stage or have constraint/branches on the transformer. I usually see a requirement for a reject report that needs to display the entire rejected record.

Do you trust your data source? Sometimes it's not (just) paranoia to answer "no". :wink:
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
tanaya.deshpande@tieto.co
Participant
Posts: 94
Joined: Sun Jul 18, 2010 11:35 pm

Post by tanaya.deshpande@tieto.co »

Thanks you guys My problem is solved :D
Post Reply