RE: Create view using CAST to change datatype

  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 19 Mar 2004 11:03:12 -0500

In the world according to Oracle, a zero-length string is indistinguishable 
from a NULL.  Yes, I'm that's incompatible w/ ANSI, but that's what Oracle 
does.  It's well documented behavior, and it's not likely to change anytime 
soon.

-Mark

-----Original Message-----
From: John Flack [mailto:JohnF@xxxxxxxx]
Sent: Friday, March 19, 2004 11:00 AM
To: oracle-l@xxxxxxxxxxxxx
Subject: RE: Create view using CAST to change datatype


That's interesting, because I thought that Oracle had changed things so that 
LTRIM(' ') would result in a string with a length of zero, which is not the 
same thing as a NULL.  Guess I was wrong - but I wouldn't depend on my being 
wrong forever because the ANSI standard says zero length <> null.

-----Original Message-----
From: Mercadante, Thomas F [mailto:thomas.mercadante@xxxxxxxxxxxxxxxxx]
Sent: Friday, 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
-----------------------------------------------------------------
----------------------------------------------------------------
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: