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 -> Re: Reading VARCHAR fileds as Integers ...

Re: Reading VARCHAR fileds as Integers ...

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Wed, 26 Nov 2003 20:51:57 -0800
Message-ID: <1069908744.894014@yasure>


Tinku wrote:
> Hi All
> I am new to Oracle so pardon
> Is it possible to do the following.
>
> I have a table with lots of VARCHAR columns. In this table We put all
> kinds of data (integers / strings / small ) etc.
> Now is it possible to define a view on this table such that I can
> "read" these varchar columns as "integer" or small if they were put in
> like that.
>
> so what it means is is the value in COL1 (of type varchar) is "4562",
> I should be able to read it as if the column type was integer and read
> it into a integer host variable.
>
> Thanks
> Ankur

As Michael has demonstrated you can do it. But given that you can ... why would you want to? It is bad design, it is not scalable, performance will be bad, and you will get to fight this bad design with every piece of code, every form that connects, every web page produduce, and every report created forever more.

Rather than finding a work-around ... Fix it!

Oh and if the columns are truly VARCHAR, rather than VARCHAR2, fix that too.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Wed Nov 26 2003 - 22:51:57 CST

Original text of this message

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