Check zeros in transformer Stage

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
Palci
Participant
Posts: 14
Joined: Thu Nov 17, 2011 10:56 am

Check zeros in transformer Stage

Post by Palci »

I have a small doubt. Please help
My source file has a col A (datatype varchar(12)) and I want to populate target col B (Datatype Smallint) with the logic that if the col A is zero then col B = 1
Now the concern is that as the source col A is having length as 12, I can get anything from 1 zero to 12 zeros in my source file (i.e. 0, 00, 000, ...... , 000000000000). :(
I don't want to get into checking 12 if clauses here. Can anyone please suggest a smarter way to do this in the transformer stage of Datastage 8.5 :?:
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

1) Use Trim to strip off '0' and then check for blank

Code: Select all

If Trim(A,'0','A')='' Then 1 else <What ever>
2) Convert Col A to integer and then check if its zero

Code: Select all

 If AsInteger(A)=0 then 1 else <What ever>
you can add IsValid if you have the appetite for it
- Zulfi
Palci
Participant
Posts: 14
Joined: Thu Nov 17, 2011 10:56 am

Post by Palci »

Thanks a lot ZULFI. This works !!
`Palci`
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi zulfi,

Code: Select all

If Trim(A,'0','A')='' Then 1 else <What ever>
here whats the use by giving of third parametre 'A'

Thanks
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

A-Removes all occurrences of character


For more information you can refer this link

http://publib.boulder.ibm.com/infocente ... ction.html
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Thank You Somuch vamsi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Kind of crazy that the functions are actually documented somewhere. :wink:

You'd also have this information in the pdf manuals delivered with the product and in the "online" help as well.
-craig

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