Rounding From Decimal to Integer In PX

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
dtatem
Participant
Posts: 54
Joined: Wed Jun 09, 2004 7:50 am

Rounding From Decimal to Integer In PX

Post by dtatem »

I have a decimal value ie 3763.8 and I want to convert to an Integer with Rounding to the next number. Therefore the expected integer value I should get is 3764. Likewise if my decimal value is 2314.2, the integer value I should get is 2314.

I have looked through the various postings but I didn't find anything that seem to work. Currently I am using AsInteger(Link.ColName)

Please let me know..

Thanks

dtatem
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Use an explicit conversion function such as int32_from_decimal in a Modify stage.
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

If you map your decimal directly to an integer field of the same length rounding should happen implicitly the way you want.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
dtatem
Participant
Posts: 54
Joined: Wed Jun 09, 2004 7:50 am

Post by dtatem »

If I map the decimal to an integer field as you suggested, would I get a warning and If I do how do I suppress the warning message?

Thanks..

dtatem
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Did you try? I'm not getting any warning in my jobs :)
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

dtatem wrote:how do I suppress the warning message?

Thanks..

dtatem
You could use message handlers to suppress or demote warning messages. More information can be found in chapter 6 of the Director guide or search the forum for discussions on the same.

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's not the same as not generating the warnings in the first place!
When you use the Modify stage add an additional specification containing the single word NOWARN.
This is not in the Parallel Job Developer's Guide but you can find it in the Orchestrate Operators 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.
dtatem
Participant
Posts: 54
Joined: Wed Jun 09, 2004 7:50 am

Post by dtatem »

JoshGeorge:

I haven't tried it as yet. To give you more information,the decimal values I posted earlier,are derived from an input declared as Dec(10,2). The input dec(10,2) are passed into the aggregate stage. The "Sum Output Column" data type is defaulting to "DOUBLE", I then use a transformer to cast the result from DOUBLE to Integer.. ie AsInteger(Link.Colname).

Should I make the data type length to Integer(10)?

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

Post by ray.wurlod »

Integer doesn't have a length. Data type int32 is always four bytes long. If your aggregated numbers are larger than this, you can use int64.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Output type of calculation column is normally double, but you can default (override) this to decimal in the aggregator. You can see this option in the properties - Available properties to add. Now as noted earlier in the transformer you can map your decimal directly to an integer field of the same length. You shouldn't get any error/ warning messages for this.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Post Reply