Substr of Decimal

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
alisoviejo
Participant
Posts: 49
Joined: Fri Nov 11, 2005 10:19 am

Substr of Decimal

Post by alisoviejo »

Hi,
If I have the source as 11.34 I need only the numbers before the decimal, i.e. 11 .

Is there a stage I can use in EE instead of conventionally using the transformer?

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

Post by ray.wurlod »

Modify stage. Use int32_from_decimal() or int64_from_decimal() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
alisoviejo
Participant
Posts: 49
Joined: Fri Nov 11, 2005 10:19 am

Post by alisoviejo »

Would that round it off or just give the number before the decimal, becasue if it is 11.98 , still we need only 11.

I do not have the access to DS now, will try your idea Ray.

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

Post by ray.wurlod »

There are optional pieces. You can specify truncation or rounding. It's all in the manual.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hi,

Use the following rounding function in the transformer. It will give your expected result.

DecimalToDecimal(ColumnName,'round_inf')

Regards
Nagesh.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
alisoviejo
Participant
Posts: 49
Joined: Fri Nov 11, 2005 10:19 am

Post by alisoviejo »

Hi Ray,

I have used

ME_TGT:int64=int64_from_decimal [trunc_zero] (ME_LOW)

ME_TGT:integer=int32_from_decimal [trunc_zero] (ME_LOW)

ME_TGT=int64_from_decimal [trunc_zero] (ME_LOW)

My source column is Real (40.8) and my target column is integer(ME_TGT).
The job aborts saying operator conversion not possible, am I missing onthe syntax. Appreciate your time.
ALISO
alisoviejo
Participant
Posts: 49
Joined: Fri Nov 11, 2005 10:19 am

Post by alisoviejo »

I got it, I changed the source column type to Decimal and the function works, thanks Ray!
ALISO
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Real and dfloat are approximate representations of data. Decimal and numeric are exact representations. They are different data types, which is why you experienced what you did. My original response was based on your statement that the data type was Decimal.
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