how do i cast string to integer in Oracle

folks

how do i cast a string value to integer or float in oracle  ie the value

100.23 is a string field type in table A  and i need to get it into tbale b as a float value using a trigger

all help wil do
rutgermonsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DocCan11Commented:
you have two functions available to you .. One is convert

select convert(datatype,value)  

ie select convert(int,mydata)
from test

or you can use to_number

select to_number(data,mask)
from test


The mask help determine the format of the new number.. see the following for a more detailed reference on to_number

http://www.techonthenet.com/oracle/functions/to_number.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fsze88Commented:
try to use to_number function. It is the most easiest way to convert string to be number
more function refers can goto
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/toc.htm
SQL> select to_number('1234.56') - to_number('234.57') result from dual;
    RESULT
----------
    999.99


SQL> create table abc
  2  (s varchar2(2000));
 
òúËh<.
 
SQL> insert into abc values ('1234.56');
 
òúË 1 Ç™.
 
SQL> commit;
 
ºŒ.
 
SQL> select to_number(s) from abc;
 
TO_NUMBER(S)
------------
     1234.56
 
SQL> select to_number(s) - 234.57 from abc;
 
TO_NUMBER(S)-234.57
-------------------
             999.99

Open in new window

0
rutgermonsAuthor Commented:
Ok thanks

but how do i convert it using a trigger?

TO_NUMBER(:NEW.ITEMQUALITY)

Doesnt work

all help will do
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.