Page 1 of 1

Need to fetch integer part from decimal data

Posted: Thu Sep 05, 2013 7:36 am
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,

Posted: Thu Sep 05, 2013 7:40 am
by chulett
Floor()

Posted: Thu Sep 05, 2013 8:21 am
by HemaV
Will the Floor() function round up if the value after decimal point is greater than 5?

Posted: Thu Sep 05, 2013 8:32 am
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)

Posted: Thu Sep 05, 2013 10:47 am
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.

Re: Need to fetch integer part from decimal data

Posted: Thu Sep 05, 2013 6:09 pm
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)


Posted: Thu Sep 05, 2013 6:40 pm
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?

Posted: Thu Sep 05, 2013 6:51 pm
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.

Posted: Fri Sep 06, 2013 1:36 am
by HemaV
when i tried with AsInteger(lnk.col1) then it removed decimal point and decimal part values.

Thanks in Advance,

Posted: Fri Sep 06, 2013 5:16 am
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?

Posted: Fri Sep 06, 2013 7:20 pm
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?