Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> 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
-----Original Message-----
From: Saira Somani-Mendelin [mailto:saira_somani_at_yahoo.com]
Sent: Friday, March 19, 2004 10:03 AM
To: oracle-l_at_freelists.org
Subject: RE: Create view using CAST to change datatype
Tom,
That's a great suggestion, but how could I do that in a view? Perhaps like this? CAST(RTRIM(OB_OID) AS NUMBER) OB_OID... would that work?
Here is the view definition:
CREATE OR REPLACE VIEW V_ITH_F
AS
(SELECT
ITH_RID,
TRANSACT,
SKU,
PKG,
FROM_LOC,
TO_LOC,
TRANSACT_STT,
WAVE,
CAST(OB_OID AS NUMBER) OB_OID,
OB_TYPE,
CAST(IB_OID AS NUMBER) IB_OID,
IB_TYPE, OB_LNO, IB_LNO,
Saira,
My first idea would be to trim the blanks from the column thus
converting
the value to a null before casting. Would that work? What happens with
the
Cast statement when a null value is involved? Can you show the Create
View
Sql?
thanks
Tom Mercadante
Oracle Certified Professional
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.htmlput 'unsubscribe' in the subject line.
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to: oracle-l-request_at_freelists.org
![]() |
![]() |