RE: Create view using CAST to change datatype

  • From: "Saira Somani-Mendelin" <saira_somani@xxxxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 19 Mar 2004 10:34:34 -0500

I'm not sure why I'm leaning towards CAST...(I claim ignorance!)

In any case, I tried methods, both yours and Igor's, and received the
same error:

ORA-01722: invalid number

Somewhere in this table, there is a strange value. I was trying to make
life simpler without having to create multiple views to deal with these
data value issues (filter the view by some criteria). 

So here's another question (just out of curiosity), how can I determine
which value is causing me problems?

Thanks for all your help so far! I appreciate the time.
Saira

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Mercadante, Thomas F
Sent: March 19, 2004 10:10 AM
To: 'oracle-l@xxxxxxxxxxxxx'
Subject: RE: Create view using CAST to change datatype

Saira,

This worked:

CREATE OR REPLACE VIEW tomview 
AS 
SELECT 
 col1, col2,
 cast(NVL(RTRIM(col1),0) AS NUMBER) col1_numb
FROM tomtest 

Values for the TOMTEST table were (' ',1);

SELECT * FROM tomview
returns

values of (' ', 1, 0)

And I agree wih Igor - why are you using CAST rather than to_number?


Tom Mercadante
Oracle Certified Professional

----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: