Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Binary_double to Number and varchar2 conversion issue

User_H7I9VJul 9 2015 — edited Jul 10 2015

Hi All,

    I need a help regarding the value conversion.

    I am using oracle 11g r2 version.

    BINARY_DOUBLE to NUMBER

    BINARY_DOUBLE to VARCHAR2

For your Reference i have created two tables testbinary  and test_stg.

desc testbinary;

Name Null Type           

---- ---- ---------------

COL1      BINARY_DOUBLE()

Below are values for each table.

select * from testbinary ;

COL1

----------

62.9765

2300142.35

desc test_stg;

Name Null Type              

---- ---- ------------------

COL1      NUMBER            

COL2      VARCHAR2(255 CHAR)

COL3      DATE         

   

select * from test_stg;

COL1

--------

Requirement is i need to select the data from testbinary  table insert to test_stg;

I am using CAST function, below is the query

insert into test_stg(col1) select cast(col1 as number(38,10)) from testbinary;

COMMIT;

select * from test_stg;

OUTPUT: after insert

COL1

---------

62.9765

2300142.3500000001

Here the problem is with "2300142.35" value when inserted to target table test_stg with "2300142.3500000001"

Could any one can help, how to insert the exact value to target table.

Please let me know if you need any further clarification.

Regards,

Sanjib

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 7 2015
Added on Jul 9 2015
17 comments
7,240 views