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

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

Re: How to put a Varchar into a Number?

From: Ken Sproule <kenmn_at_tds.net>
Date: Wed, 09 Feb 2000 15:54:59 GMT
Message-ID: <iv23as82cl3t3ld7evrqt9shfmj5gt5334@4ax.com>


On Wed, 09 Feb 2000 13:48:49 +0100, Pierre Charpenay <pcharpenay_at_unilog.fr> wrote:

>
>
>Ken Sproule wrote :
>
>>
>> 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 . '.' );
>
>What is this ? (equivalent for MyVar=replace(MyVar, '.') (remove the
>point) ? Are you sure of the result ?

Yes, this gives the number of nickles in a value that is divisible by 5.
>
>>
>> MyNum := MyVar; -- *********** Blows here
>
>If MyVar is correct, the to_number() function must work.

MyNum := to_number(MyVar); does not work. what will work but is not the answer to the problem is this:

update Table_Named_Test set test_cur.SomeNUMBERcolumn = to_number( replace( MyVar , '.')) / 5 where ....... ;

The problem seems to be that Oracle is not converting things when the variable is DECLARED in the trigger, but it does if the conversion is done directly to a REAL Table's column.

How do I do this to a DECLARED variable like MyNum above?

>
>>
>> END;
>
>Bye.

Ken Sproule
kenmn_at_tds.net Received on Wed Feb 09 2000 - 09:54:59 CST

Original text of this message

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