Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Setting view column datatype

Setting view column datatype

From: Brian Dick <bdick_at_cox.net>
Date: Mon, 19 Jan 2004 12:46:31 -0500
Message-ID: <XJUOb.19335$Mb7.9762@lakeread04>


Some of my view columns have numeric table columns as their underlying values, and some view columns have numeric expressions as their underlying values. If you describe the view, the datatype for the view column with numeric table columns show the table column datatype, including the precision and scale. However, the view columns with numeric expressions only show NUMBER. I would like to restrict the view columns with numeric expressions to an explicit datatype, e.g. NUMBER(5). I tried wrapping the expression with a cast(... as number(5)) to no avail.

I really need this capability, because I am using the view metadata to generate JDBC code. With a specified precision and scale I can generate Java native datatypes. With an unspecified precision, I have to resort to generating BigDecimal Java class instances. I prefer using native Java datatypes because of their performance advantage over Java class instances.

Does anyone know how to explicitly set a view column's datatype?

Later,
BEDick

OS: Win2K
Oracle: 9.2.0.4

Example:

ORA> create or replace view foo
  2 as
  3 select 1 * rownum an_expression
  4 from dual;

View created.

ORA> desc foo

 Name                          Null?    Type

----------------------------- -------- --------------------
AN_EXPRESSION NUMBER

ORA> create or replace view foo
  2 as
  3 select cast(1 * rownum as number(5)) an_expression   4 from dual

View created.

ORA> desc foo

 Name                          Null?    Type

----------------------------- -------- --------------------
AN_EXPRESSION NUMBER
Received on Mon Jan 19 2004 - 11:46:31 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US