Page 1 of 1

Decimal Rounding and convert to Varchar

Posted: Mon Apr 11, 2011 11:58 pm
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?

Posted: Tue Apr 12, 2011 12:41 am
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.

Posted: Tue Apr 12, 2011 6:29 am
by abhilashnair
Just changed metadata of target seq file to Integer. So rounding happens automatically

Posted: Tue Apr 12, 2011 4:46 pm
by ray.wurlod
That changes the question.

Posted: Wed Apr 13, 2011 2:02 am
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