insert on insert/update

From: Haris Susanto <hariss(at)dnet(dot)net(dot)id>
To: pgsql-sql(at)hub(dot)org
Subject: insert on insert/update
Date: 1999-06-23 04:39:21
Message-ID: 377064F8.88F0DFC@dnet.net.id
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Help me, I have problem to solve the following case :

I have two tables with structure like these :

table_a
date id type amount
---------------------------------
01/06/99 01 a 200 (1)
01/06/99 02 a 900 (2)
05/06/99 01 b 300 (3)
01/07/99 01 a 500 (4)

table_b
date id balance
------------------------
01/06/99 01 -200 (A)
01/06/99 02 -900 (B)
05/06/99 01 100 (C)
01/07/99 01 -400 (D)

Everytime I insert a record into table_a or update the value of amount of a record, automatically
postgres insert a record into table_b.

For exampe if I insert a record (4)
Then the value of (D) :
table_b.date same as table_a.date
table_b.id same as table_a.id
table_b.balance = -200 + 300 + (-500)

Would somebody please tell me how to make it happen ?

Thanks a lot !

Browse pgsql-sql by date

  From Date Subject
Next Message Darren Greer 1999-06-23 11:54:20 oidrand question
Previous Message Min Qiu 1999-06-23 04:19:27 Are int4/int8 ops defined?