Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> How to put a Varchar into a Number?

How to put a Varchar into a Number?

From: Ken Sproule <kenmn_at_tds.net>
Date: Wed, 09 Feb 2000 02:47:49 GMT
Message-ID: <6ml1as834vrg4jnr5v6iaelq8r3i32ef8i@4ax.com>

To those who have helped me already, thanks again. And, to those who help in the future thanks in advance.

I have been trying a syntax similar to the following:

DECLARE

	MyNum		NUMBER(20,2);
	MyVar		VARCHAR2(20);
	CURSOR test_cur is select * from XXXX;
	test_val test_cur%ROWTYPE;

BEGIN
	Open test_cur;
	Fetch test_cur into test_val;
	-- test_val.cost is a a VARCHAR2 with this in it =è '006.100'
	MyVar := test_val.cost ;
	REPLACE( MyVar . '.' );
	MyNum := MyVar; -- *********** Blows here 

END;   I thought Oracle would automatically convert the Varchar2 in the line marked "*********** Blows here" to a NUMBER. However, that does not seem to work. Using TO_NUMBER(MyVar ); doesn't work either;

Does any one know how I can convert a Vaarchar2 into a Number so I can then do a ( MyNum / 5 )?

Best,

Ken Sproule
Kenmn_at_tds.net Received on Tue Feb 08 2000 - 20:47:49 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US