Calculated fileds in pg

From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Calculated fileds in pg
Date: 2002-11-24 08:15:46
Message-ID: 3DE08AB2.3020904@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is it possible to set up a field during table creation to be a
"calculated" field, i.e. the value is calculated from other values.

For example:

Table A:

id integer primary key,
B_id integer references B(id),
cost integer default 0

Table B:

id integer primary key,
total integer -- select sum(cost) from A where B_id=id;

If not should I be looking at implementing this with a view or maybe a
trigger?

Thanks,

Jc

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Christian Imbeault 2002-11-24 08:41:50 test
Previous Message Gordon P. Oliver 2002-11-24 06:53:16 FATAL 1: Memory exhausted in AllocSetAlloc()