Solved

Oracle and Numbers (Currency)

Posted on 2012-04-06
4
486 Views
Last Modified: 2012-04-08
I am importing data from a csv that has numbers with currency. I am importing the columns as a number field but once the data is imported it is rounded off..

everything that is 0.50 becomes 1

should i be importing this data as varchar? it is going to be dealing with purely numbers with decimal places, i may need to end up with a number like 91.242879
0
Comment
Question by:gnivkor
4 Comments
 
LVL 23

Accepted Solution

by:
OP_Zaharin earned 500 total points
ID: 37816543
- you can use the datatype Number with 2 precision such as Number(7,2).

- then when importing format the currency data using to_number as follow:
to_number(replace(x,' '),'L999,999,999.99')
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37816610
What tool are you using to import the data?

By default Oracle numbers can handle decimals without rounding:

SQL> create table tab1(col1 number);

Table created.

SQL> insert into tab1 values(1.23456789);

1 row created.

SQL> select * from tab1;

      COL1
----------
1.23456789

Open in new window

0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37816889
You could use a regular expression in your control file something like this:
...Etc...
numcolx     "REGEXP_REPLACE( :numcolx, '([:ALPHA:]|[,])', '' )".
...Etc...

Open in new window

:p
0
 
LVL 16

Expert Comment

by:Wasim Akram Shaik
ID: 37817004
I think, this might be the problem within tool( generally people use excel) to open csv file) itself, unless you specify explicitly oracle won't round it off for you(as mentioned in comment http:a#37816610)

try to format in the tool(assuming excel) to see whether the column is formatted as to specify the nearest integer ..!!!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question