String to Decimal Validation

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

Post Reply
SettValleyConsulting
Premium Member
Premium Member
Posts: 72
Joined: Thu Sep 04, 2003 5:01 am
Location: UK & Europe

String to Decimal Validation

Post by SettValleyConsulting »

In a transformer, fitted with a reject link, I am mapping a string to a decimal type.

What I want to happen:-

If the incoming data is not a numeric string, e.g. 'aaaa' I want the row to be shunted into the reject link.

What actually happens (to my surprise)

The value is defaulted to zero, a warning is issued to the log, however the row continues on its merry way.

Is there any way of making the transformer behave the way I want? Or do I have to code up a validation for each and every decimal?
Phil Clarke
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Unfortunately, I would say that you would need to code up a "IsValid()" for each of those conversions.
SettValleyConsulting
Premium Member
Premium Member
Posts: 72
Joined: Thu Sep 04, 2003 5:01 am
Location: UK & Europe

Post by SettValleyConsulting »

Thank, Arnd. I'd pretty much come to the same conclusion, just wondering if there was some obscure option to switch on strong typing .....
Phil Clarke
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If all of the decimals have the same behaviour plus your source is a sequential stage, you could do the conversion from string to decimal implicitly when reading the data and then specify handling for decimals in the stage attributes.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Just for my understanding does that mean that the output row has to fail before its written to an reject link? eg trying to convert something for which there is no conversion.

And since the value here would be defaulting during its conversion that is not a failure hence no reject?
Last edited by ShaneMuir on Wed Aug 08, 2012 1:43 am, edited 1 time in total.
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

String function Num() confirms that the string can be converted to a number. It is available in the Transformer constraints. The Otherwise/log function looks promising, Parallel Job Developer's Guide (7.x) page 16-17.
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
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Hi Franklin

I think that is what Phil was trying to avoid - ie having a validation check for the field (whether it be IsValid() or Num()).

By having the conversion from string to decimal, and a reject link, it was hoped that when the conversion encountered a non numeric value that this would 'fail' and be sent down the reject link, removing the need to code a validation check. My understanding is that what actually happened is that the conversion from string to decimal has merely replaced a non numeric value with a default value of 0 and continued on its merry way.
Post Reply