Cascading Updates

From: Marcus Mascari <mascarim(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Cascading Updates
Date: 1999-01-29 09:04:58
Message-ID: 19990129090458.19008.rocketmail@send105.yahoomail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello.

I was wondering if it is possible, using the current
refint.c code, to perform CASCADING UPDATES. It
appears that the trigger will fire on either an
update or a delete and call check_foreign_key() to
perform deletes ('cascade') or updates with NULL's
('setnull'), but not updates with the new key.

Am I missing something, or should you be able to
have the following:

CREATE TABLE employees (
employee varchar(10) not null
);

CREATE TABLE payroll (
employee varchar(10) not null,
salaray double not null
);

INSERT INTO employees VALUES ('mascarim');
INSERT INTO payroll VALUES ('mascarim','1250000');

and a trigger which, when the employee id
is updated:

UPDATE employees SET employee = 'mmascari' WHERE
employee = 'mascarim';

in the employees table, cascades to
update the employee id in the payroll table.

Is this currently not possible? It appears that
the result is that an update to the employees
table, will yield a DELETE in the payroll table
instead of an update.

Any hints would be greatly appreciated.

Thanks,

Marcus Mascari (mascarim(at)yahoo(dot)com)

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marcus Mascari 1999-01-29 10:35:09 Cascading Updates
Previous Message Charles Hornberger 1999-01-29 07:06:08 nested loops in joins, ambiguous rewrite rules