?
Solved

Oracle and Numbers (Currency)

Posted on 2012-04-06
4
Medium Priority
?
495 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 77

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.
Suggested Courses

777 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