Home » SQL & PL/SQL » SQL & PL/SQL » Formating/Converting Words to numbers
Formating/Converting Words to numbers [message #2033] Tue, 18 June 2002 06:11 Go to next message
Godwin
Messages: 37
Registered: January 2002
Member
Please help with this problem. I want to convert a number say 5000 of data type varchar2 to the same number of data type number but if i use say " select to_number(5000) from dual" the figure 5000 is left padded with space ie. ----5000 where - represents space.
How then do i remove such leading spaces so i can store the formatted number in a table.
Re: Formating/Converting Words to numbers [message #2035 is a reply to message #2033] Tue, 18 June 2002 09:57 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Once you use the to_number function, the result is a number datatype. For display purposes, it may be right-aligned, but it is still a number.

In any case, you actually don't even need to explicitly convert the datatype (unless you want to), because Oracle will convert it implicitly.

sql>create table t (varchar2_column varchar2(10), number_column number);
 
Table created.
 
sql>insert into t values ('4000', null);
 
1 row created.
 
sql>update t set number_column = varchar2_column;
 
1 row updated.
 
sql>select * from t;
 
VARCHAR2_C NUMBER_COLUMN
---------- -------------
4000                4000
Previous Topic: updating a table via a function wich is called by sql statements
Next Topic: converting bytes to human friendly string`
Goto Forum:
  


Current Time: Thu Apr 25 16:44:32 CDT 2024