Rounding Decimal in Transformer

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
hsbc_ds_dev
Premium Member
Premium Member
Posts: 22
Joined: Tue Oct 31, 2006 5:16 pm

Rounding Decimal in Transformer

Post by hsbc_ds_dev »

Hi,

My source field is Decimal(26,3) and the target field is Decimal(7,0). I just want to have first 7 digits from the incoming value into my target column.

For example,
If incoming value is 1234567890123.999, then the target should have 1234567. I want to manipulate this within a Transformer (parallel) stage only.

Any guidance?

Thanks.
prasad.bodduluri
Participant
Posts: 30
Joined: Tue Jan 30, 2007 5:21 am
Location: bangalore

Post by prasad.bodduluri »

there is function in server jobs , i.e is fix
prasad
sanjay.v
Participant
Posts: 2
Joined: Tue Nov 21, 2006 1:19 am

Post by sanjay.v »

First try using DecimalToDecimal function in transformer... and check for required output...
If this doesn't work, try this first convert the decimal field into string and use the string function Left() to get the first seven digits.Once you get this, convert this result back to Decimal for target mapping...

thanks,
sanjay
hsbc_ds_dev
Premium Member
Premium Member
Posts: 22
Joined: Tue Oct 31, 2006 5:16 pm

Post by hsbc_ds_dev »

Prasad, I already mentioned it's a Parallel job and I'm using a parallel transformer. And your reply anyway is not getting into my brain.

Sanjay, I tried doing it your way. DS is not giving proper output for records that have bigger numbers than the INT32 max value.

Could anyone help me out?

Thanks!
Zhang Bo
Participant
Posts: 15
Joined: Sun Jul 15, 2007 9:22 pm

Post by Zhang Bo »

you should try sanjay.v's second solution, that works.FYI,
StringToDecimal(Left(DecimalToString(DSLink3.a,"suppress_zero"),7))
MaDFroG
hsbc_ds_dev
Premium Member
Premium Member
Posts: 22
Joined: Tue Oct 31, 2006 5:16 pm

Post by hsbc_ds_dev »

Thanks Zhang Bo,
What a coincidence!!! I could just achieve it with some logic and then saw your reply - the logic given by you is exactly same what I've used :D
Post Reply