Re: Joined table view - multiple delete action rule - Mailing list pgsql-general

From Gyozo Papp
Subject Re: Joined table view - multiple delete action rule
Date
Msg-id 014601c0cdcf$7ab54bc0$2047c5d5@jaguar
Whole thread Raw
In response to Re: Joined table view - multiple delete action rule  (Jan Wieck <JanWieck@Yahoo.com>)
List 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@freestart.hu


pgsql-general by date:

Previous
From: Dale Walker
Date:
Subject: playing with timestamp entries
Next
From: Tom Lane
Date:
Subject: Re: playing with timestamp entries