Round to 2 decimal places For Double (53)

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
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Round to 2 decimal places For Double (53)

Post by ds2000 »

i want to Round to 2 decimal places input and output is same i.e double (53)
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Good on you, I am certain that you can do this in DataStage.

But if you want help in doing this, you need explain exactly what it is you are asking - what stage, converting from what type to what type?
Last edited by ArndW on Wed Jan 02, 2008 12:26 pm, edited 1 time in total.
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Post by ds2000 »

I want to do this in Transformer in Px and source is Double (53) and Target is Double (53) in dataset which is then populated in db2 - Double (53).
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You could round mathematically, i.e. INT(In.DBLCol*100)/100 or use an interim Decimal data type with 2 decimal places.
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Code: Select all

sravanthi: Try OCONV(col,"MD2") 
I guess this is a parallel job and OCONV will not work unless Basic transformer is used. :wink:
Thanks and Regards!!
dspxlearn
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Post by ds2000 »

ArndW:
INT(In.DBLCol*100)/100 function is not available in px. and i tried to put decimal with 2 decimal places, it doesnt round.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

PX has 2 functions that do this : CEIL and FLOOR. Try

Code: Select all

FLOOR(In.DBLCol*100)/100
Note this will truncate, not round. For rounding you should first do a decimal conversion using rtype "round_inf"
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Post by ds2000 »

ArndW:
I couldn't understand it. what is the syntax of round_inf ? please explain.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I just did a bit of checking for correct syntax in the modify stage and noticed that there are actually 2 simple ways to do this. If your input column is called "Test" and has [10,4] defined then

NewTest1:Decimal[10,2]=Test
NewTest2:Decimal[10,2]=Decimal_From_Decimal [round_inf] (Test)

will both return rounded decimals to 2 places. This means that the implicit conversion will work just as well as explicitly using the "round_inf".
ds2000
Premium Member
Premium Member
Posts: 109
Joined: Sun Apr 22, 2007 7:25 pm
Location: ny

Post by ds2000 »

DFloatToDecimal(Link.DblCol, "round_inf") works fine in transformer when making stage variable to Decimal with 2 decimal places. Would it be able to handle a value for Double (53). What should be the decimal data type equivalent to Double (53) ?
Post Reply