Home » SQL & PL/SQL » SQL & PL/SQL » Store currency into table
Store currency into table [message #204456] Mon, 20 November 2006 19:34 Go to next message
ntc2000
Messages: 25
Registered: September 2005
Junior Member
hi all,

How can I store the currency format into db??

Scenario:
I have a currency amount let said 10,000.00, how can i stored it into the db[number(10,2)] without using javascript formatting it to 10000.00??

Is that possible to store the comma into then db using jstl?


Thank.
Re: Store currency into table [message #204468 is a reply to message #204456] Mon, 20 November 2006 22:33 Go to previous messageGo to next message
romi
Messages: 67
Registered: October 2006
Member


Try it:-

Select to_char(10000,'99,999.99') from dual;



Re: Store currency into table [message #204471 is a reply to message #204456] Mon, 20 November 2006 22:37 Go to previous messageGo to next message
rameshuddaraju
Messages: 69
Registered: June 2005
Location: India
Member

Number does not accept formats.
we don't have a specific data type to store currency values.
We are using number data type only.
If you want to store 10,000.00 in db it should be in a column of varchar2 data type.

Varchar2 stores 10,000.00 as string so, you can not perform calculations unless you convert into a number by using to_number function.

Example of to_number function
to_number(colname,'99,999.99')
Re: Store currency into table [message #204589 is a reply to message #204471] Tue, 21 November 2006 06:07 Go to previous messageGo to next message
Littlefoot
Messages: 20900
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
It is a bad idea to store numbers as characters. It does not solve anything, but brings problems all around.

There's no need to store "10,000.00" in this format - simply store it into a NUMBER datatype column as "10000" and later, for reporting purposes, use format mask.
Re: Store currency into table [message #204772 is a reply to message #204589] Wed, 22 November 2006 01:18 Go to previous messageGo to next message
moparthy99
Messages: 13
Registered: July 2006
Junior Member
We can not store number in format only way we can retrive in a
required format
Re: Store currency into table [message #204867 is a reply to message #204772] Wed, 22 November 2006 07:38 Go to previous messageGo to next message
joy_division
Messages: 4642
Registered: February 2005
Location: East Coast USA
Senior Member
Sometimes I think people are typing with their tongues or their noses here. What a poor grammatical sentence with no punctuation that is, and just a repeat of what Littlefoot already has said.
Re: Store currency into table [message #204945 is a reply to message #204456] Wed, 22 November 2006 15:42 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
If what you are saying is that you have a character string of "10,000.00" and you want to store it in a number field, then do the following.


insert into my_table values(to_number(replace('10,000.00',',')));
Previous Topic: send excel file as attachment thru a plsql email
Next Topic: Mutating tables
Goto Forum:
  


Current Time: Thu Dec 08 08:46:35 CST 2016

Total time taken to generate the page: 0.12398 seconds