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: Computed column?

Re: Computed column?

From: Michael Serbanescu <mserban_at_postoffice.worldnet.att.net>
Date: 1997/07/14
Message-ID: <33CAD654.3A59@postoffice.worldnet.att.net>#1/1

You can try to do it in several ways:

First possible solution:

Create the table 'Test' with column A integer, column B integer.

CREATE OR REPLACE VIEW v_test
AS
SELECT A, B, (A+B)/10 AS C
FROM Test;

Second solution:

Create table Test with column A integer, column B integer, column C number (n, m)

Create a trigger which will insert/update in C the computed value (A+B)/10.

Third solution: (works only if your table is a one-time thing):

Create table Test1 with column A integer, column B integer

CREATE TABLE Test
AS
SELECT A, B, (A+B)/10 AS C
FROM Test1
UNRECOVERABLE; DROP TABLE Test1;

Hope this helps.

Michael Serbanescu



Jane Mikityanskaya wrote:
>
> Working with Oracle Rdb, I was spoiled by possibility of creating
> 'computed by' columns.
> For example, creating table ' Test' I could define:
> column A integer,
> column b integer,
> column c as (a+b)/10;
> Since there is no such feature in Oracle 7.3, can someone tell me a work
> around for 'computed' fields?
>
> Regards,
> Jane
  Received on Mon Jul 14 1997 - 00:00:00 CDT

Original text of this message

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