Home » SQL & PL/SQL » SQL & PL/SQL » Problem with to_char function (Oracle 10g)
Problem with to_char function [message #407951] Fri, 12 June 2009 09:49 Go to next message
Ronald Beck
Messages: 121
Registered: February 2003
Senior Member
I am having a problem with the to_char function when trying to change a number to a character string. Here's what I've tried:


SQL> select '>>>'||to_char(23,'009')||'<<<' from dual;

'>>>'||TO_
----------
>>> 023<<<

SQL> 


Notice that my result shows ">>> 023<<<", and what I want is ">>>023<<<". What am I missing here?

Thanks,
Ron
Re: Problem with to_char function [message #407952 is a reply to message #407951] Fri, 12 June 2009 09:54 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
>What am I missing here?
TO_CHAR is providing room for the minus sign should the number be negative
Re: Problem with to_char function [message #407954 is a reply to message #407952] Fri, 12 June 2009 10:03 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Have a look here, and be on the lookout for "fm" specifically.
Re: Problem with to_char function [message #407955 is a reply to message #407951] Fri, 12 June 2009 10:03 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL Reference
Chapter 2 Basic Elements of Oracle SQL
Section Format Models
Table 2-14 Results of Number Conversions

Regards
Michel


Re: Problem with to_char function [message #407956 is a reply to message #407951] Fri, 12 June 2009 10:23 Go to previous message
Ronald Beck
Messages: 121
Registered: February 2003
Senior Member
Thanks all. I had forgotten about the sign of the number. Most of my to_char work is with dates & times, not numbers.

Ron
Previous Topic: ORA:28234 - 10g
Next Topic: PLS-00304: cannot compile body of 'ETL_VALIDATION_PCK' without its specification
Goto Forum:
  


Current Time: Sat Dec 10 01:16:07 CST 2016

Total time taken to generate the page: 0.13338 seconds