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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to create computed field/column in a table

Re: How to create computed field/column in a table

From: Jim Kennedy <kennedy-family_at_home.com>
Date: Tue, 20 Nov 2001 14:09:05 GMT
Message-ID: <5utK7.50801$XJ4.29682154@news1.sttln1.wa.home.com>


It is computed. It is not stored as a computed column, but any external application won't know that. The other way is to write a trigger that sets the value of the value3 column on insert or update or value1, value2. Jim
"Jesper S. Knudsen" <jesper.stougaard.knudsen_at_omgroup.com> wrote in message news:u0qK7.214$%X5.3304821778_at_news.euroconnect.net...
> Hi Richard
>
> Thank you for your answer. But it has to be a computed field/column. Do
you
> know how?
>
> Gr.
>
> Jesper
>
> "Richard B" <someguyonthenet_at_hotmail.com> wrote in message
> news:3bfa4f8d_at_peer1.news.newnet.co.uk...
> >
> > "Jesper S. Knudsen" <jesper.stougaard.knudsen_at_omgroup.com> wrote in
> message
> > news:WxmK7.207$w04.3163937823_at_news.euroconnect.net...
> > > Hi
> > >
> > > Does anyone know how create a computed column in a table?
> > >
> > > In MS SQL Server you do it like this:
> > >
> > > CREATE TABLE mytable (
> > > key numeric not null primary key,
> > > value1 numeric not null,
> > > value2 numeric not null,
> > > value3 as (value1*value2)
> > > )
> > >
> > > How is it done in Oracle?
> > >
> > > Gr.
> > >
> > > Jesper
> > >
> > >
> >
> > The simplest way is to create a view against the table.
> > Eg.
> >
> > CREATE TABLE mytable (
> > value1 number not null,
> > value2 number not null);
> >
> > CREATE VIEW v_mytable as
> > SELECT value1, value2, (value1 * value2) as value3
> > FROM mytable;
> >
> >
> > The drawback with this method is that you can't update the value3 colum
> > directly. But presumably Transact-SQL wouldn't let you do this either.
> >
> >
> > -Richard
> >
>



> > ====
> >
> > "Propose to an Englishman any principle, or instrument, however
admirable,
> > and you will observe that the
> >
> > whole effect of the English mind is directed to find a difficulty, a
> defect,
> > or an impossibility in it.
> >
> > If you speak to him of a machine for peeling a potato, he will pronounce
> it
> > impossible;
> >
> > if you peel a potato with it before his eyes, he will declare it
useless,
> > because it will not slice a pineapple."
> >
> > -- Charles Babbage
> >
> >
>


> > ====
> >
> >
> >
>
>
Received on Tue Nov 20 2001 - 08:09:05 CST

Original text of this message

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