plpgsql trigger on a cascaded delete - Mailing list pgsql-general

From Creager, Robert S
Subject plpgsql trigger on a cascaded delete
Date
Msg-id 10FE17AD5F7ED31188CE002048406DE8514D16@lsv-msg06.stortek.com
Whole thread Raw
List pgsql-general
Hey all,

I have 3 tables - A refers to B and C, and A has ON DELETE CASCADE for
referring columns.  I'm trying to delete from B, and through the CASCADE to
A's BEFORE DELETE TRIGGER, SELECT a value from B, and then UPDATE C.  The
problem is that through this path, when I SELECT from B, the selection
criteria doesn't exist - it's already been deleted (until the trigger throws
an exception, then it's back).  Is there an easy way around this?  I'm sure
I can gin up another BEFORE DELETE TRIGGER for B, SELECT everything I want
to delete from A, and delete it in a loop in B's trigger, but was hoping for
an 'easier' solution.  Note that the trigger works fine when deleting from A
directly...

Thanks,
Rob

Robert Creager
Senior Software Engineer
Client Server Library
303.673.2365 V
303.661.5379 F
888.912.4458 P
StorageTek
INFORMATION made POWERFUL



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: URL for gmake
Next
From: Mike Castle
Date:
Subject: Re: URL for gmake