Need to fetch integer part from decimal data

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
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

Need to fetch integer part from decimal data

Post by HemaV »

my source data contains value as "1234.56" which is of decimal(17,2) datatype.

In my target table:
i want only the integer part of above value appended with zeroes at the starting for varchar2(16) datatype.
in target value needed is "0000000000001234"

Please let me know what function can be used to take only integer value without dot.

Thanks in advance,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Floor()
-craig

"You can never have too many knives" -- Logan Nine Fingers
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

Post by HemaV »

Will the Floor() function round up if the value after decimal point is greater than 5?
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

No.

From the Parallel Job Developer's Guide

Floor Calculates the largest integer value less than or equal to the given decimal value.
- Input: number (dfloat)
- Output: result (int32)
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As noted, no since that's not what you asked for... and a quick check of the documentation would have answered your question. If you ever need that functionality, the Ceil() function would be appropriate.
-craig

"You can never have too many knives" -- Logan Nine Fingers
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Need to fetch integer part from decimal data

Post by SURA »

HemaV wrote:target value needed is "0000000000001234"

Please let me know what function can be used to take only integer value without dot.

Thanks in advance,

Why can't you use

Code: Select all


Field(in.source,'.',1)

Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A curious suggestion from someone who has "performance driven outcomes" in his signature block!

How many data type conversions (implicit or otherwise) does your "solution" require?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

Ray

Nothing to do with signature:)

Its all about providing the number of ways things can be handled and the poster will get an idea about handling the ways!!

I do failed to add a point at the time when i post my comment as "Ugly way" :)

But you are our DS guru and i am in the same page with your comment.
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

Post by HemaV »

when i tried with AsInteger(lnk.col1) then it removed decimal point and decimal part values.

Thanks in Advance,
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

HemaV wrote:when i tried with AsInteger(lnk.col1) then it removed decimal point and decimal part values.
Did that retained 0's in the in the output as you wanted in the first post?
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

HemaV wrote:when i tried with AsInteger(lnk.col1) then it removed decimal point and decimal part values.
Isn't that what you wanted?
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