Decimal Rounding and convert to Varchar

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
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

Decimal Rounding and convert to Varchar

Post by abhilashnair »

I have a requirement wherein I need to round off incoming decimal data and convert to varchar and then right to seq file without leading or trailing zeroes.
Rounding Off condition as below

Suppose data is 345.5 or lower output should be 345 and if it is greater than 345.5 then output should be 346.

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

Post by ray.wurlod »

Use the rtype argument to manage your rounding, and Trim() to remove leading and trailing zeroes. It's slightly more complex with signed decimal numbers.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

Post by abhilashnair »

Just changed metadata of target seq file to Integer. So rounding happens automatically
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That changes the question.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

Post by abhilashnair »

ray.wurlod wrote:That changes the question. ...

:D
Yes. I know. But the target was sequential file. So decided to have target metadata changed to integer since the priority was rounding rather than having metadata as varchar
Post Reply