Re: Joined table view - multiple delete action rule

From: "Gyozo Papp" <pgerzson(at)freestart(dot)hu>
To: "Lieven Van Acker" <lieven(at)elisa(dot)be>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Joined table view - multiple delete action rule
Date: 2001-04-25 21:08:09
Message-ID: 014601c0cdcf$7ab54bc0$2047c5d5@jaguar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I came up against the same (or similar) difficulty some month ago.
Then Tom Lane suggested me to write a simple sql or plpgsql function which handles the multiple delete action.
(BTW, maybe you don't want to use the on delete cascade referential integrity in some cases.)

Sorry, but I can't find anywhere the answer sent me.
But here's the source code of the function I wrote:

create function f_privateauto_del(ID) returns BOOLEAN as
'DECLARE ID INTEGER;
BEGIN
SELECT INTO ID c_id FROM t_one WHERE t_one.c_id = $1;
IF NOT FOUND THEN RAISE EXCEPTION ''Illegal parameter''; END IF; -- this isn't necessary

DELETE FROM t_one WHERE oid = $1;
DELETE FROM t_two WHERE c_id = ID;
RETURN true::BOOLEAN;
END;'
language 'plpgsql';

You can figure out from my original letter (below) how much your problems is similar to the one I had.

Papp Gyozo
- pgerzson(at)freestart(dot)hu

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dale Walker 2001-04-25 21:23:19 playing with timestamp entries
Previous Message Tom Lane 2001-04-25 21:03:51 Re: Performance: sql functions v. plpgsql v. plperl