Connecting Tech Pros Worldwide Forums | Help | Site Map

How to add $ sign to number data type?

Newbie
 
Join Date: Jan 2008
Posts: 4
#1: Jan 30 '08
Hi Everybody,

I am fetching number data from a table. i want to add '$' sign to this data.
I already tried "TO_CHAR" function. This works fine but it converts number data type to string data type. I want it to be in number format only.
So, is there any way or any function that add '$' sign to number data without converting its data type?

Amit parmar

debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#2: Jan 30 '08

re: How to add $ sign to number data type?


If you want to use string data it will be string only.

If retrieving only for display then try to concadinate the $ with the data.
Member
 
Join Date: Jan 2008
Posts: 94
#3: Jan 30 '08

re: How to add $ sign to number data type?


YOU HAVE TO USE TO_CHAR FUNCTION.

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT TO_CHAR(SAL,'$99,999.00') FROM EMP;
  3. declare
  4.    v_num number;
  5. begin
  6.    v_num := to_number('$1234567.67','$9999999.99');
  7. end;
  8.  
  9.  
Newbie
 
Join Date: Jan 2008
Posts: 4
#4: Jan 31 '08

re: How to add $ sign to number data type?


Quote:

Originally Posted by debasisdas

If you want to use string data it will be string only.

If retrieving only for display then try to concadinate the $ with the data.

Hi Debasisdas,

Thanks for your reply,
As i said, i want it in number or money data type only. If i concatenate number with $ sign then the result would be in string data type that i don’t want.
If you know how to convert number data type to money data type then it would also helpful to me.

Amit Parmar
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#5: Jan 31 '08

re: How to add $ sign to number data type?


Quote:

Originally Posted by Amit Parmar

Hi Debasisdas,

Thanks for your reply,
As i said, i want it in number or money data type only. If i concatenate number with $ sign then the result would be in string data type that i don’t want.
If you know how to convert number data type to money data type then it would also helpful to me.

Amit Parmar

Oracle does not provide any thing as MONEY DATA TYPE.

Check out post #3 of this thread on how to concateate "$" symbol before the salary or any amount column to be displayed as $000.00.
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#6: Jan 31 '08

re: How to add $ sign to number data type?


Quote:

Originally Posted by Amit Parmar

Hi Debasisdas,

Thanks for your reply,
As i said, i want it in number or money data type only. If i concatenate number with $ sign then the result would be in string data type that i don’t want.
If you know how to convert number data type to money data type then it would also helpful to me.

Amit Parmar

There is nothing like money datatype in oracle .
If you want to store pure numbers store in numbers else go for char type.
Reply