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?
 
DocCan11Connect With a Mentor Commented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.