Decimal to integer

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

somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Decimal to integer

Post by somu_june »

Hi,

Iam using an stagevariabe as integer .ex total (variable)

Total(integer) = Total(integer)+Reclinenumber(decimal). I want this Reclinenumber to convert to integer.How to convert decimal to integer can I take it asinteger function to convert decimal to string. Please help me


Thanks
Somaraju
somaraju
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

AsInteger may generate warnings, because the potential exists for your decimal number to be too large to fit in an integer. If you can be 100% certain that this will never be the case, equip a message handler for this message in this job to demote the warning to informational.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
somu_june
Premium Member
Premium Member
Posts: 439
Joined: Wed Sep 14, 2005 9:28 am
Location: 36p,reading road

Post by somu_june »

Hi Ray,


Sorry Iam not able to understand. What is this equip a message. Is there any solution for this . please help me.


Thanks
Somaraju
somaraju
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No. DataStage will always generate the warning. Because you need the warning. If you want to you can create a message handler to demote the warning to an informational message. Search is your friend.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Somu

The easiest way is to convert your decimal to integer use AsInteger

Total(integer) = Total(integer)+AsInteger(Reclinenumber(decimal)).
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

How can we convert an integer to string, we have source column as 2 , and we need it to be padded with 0s for lenght of 3 i.e. 002.


Thanks,
Thanks,
Vinay
vcannadevula
Charter Member
Charter Member
Posts: 143
Joined: Thu Nov 04, 2004 6:53 am

Post by vcannadevula »

vinaymanchinila wrote:How can we convert an integer to string, we have source column as 2 , and we need it to be padded with 0s for lenght of 3 i.e. 002.


Thanks,

You can use the padstring() function
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Thanks for the inputs, when I used PadString() its padding at the end so its making a 1 to 10 , I was expecting 01 !
Thanks,
Vinay
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Use MantissaFromDecimal or need to pad the string of 0s to the left of the existing number manually after calculating the length (digint) of the existing number.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Right now using FMT(SrcColumn, "2'0'R") , wil post it if I come across any better ideas.
Thanks,
Vinay
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Are you using transformer or BasicTransformer?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

The basic transformer.

Thanks,
Thanks,
Vinay
vsurap
Participant
Posts: 6
Joined: Sun Apr 25, 2004 5:24 pm

Post by vsurap »

Right( ("000":SrcColumn) , 3 )
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi,
FMT(SrcColumn, "4'0'R") was working fine but when it hits a -ve number it pads like this 00-12 instead of -012 .
Any ideas on how to correct this !

Thanks,
Thanks,
Vinay
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

(If (SrcColumn < 0) Then "-" Else "") : Fmt(Abs(SrcColumn), "R%" : (4 - (SrcColumn < 0))) 
or

Code: Select all

If SrcColumn < 0 Then "-" : Fmt(Abs(SrcColumn), "R%3") Else Fmt(SrcColumn, "R%4")
"R%4" is another way to represent "4'0'R" but fewer keystrokes.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply