?
Solved

Oracle and Numbers (Currency)

Posted on 2012-04-06
4
Medium Priority
?
499 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 2000 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 78

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

864 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