plpgsql trigger on a cascaded delete

From: "Creager, Robert S" <CreagRS(at)LOUISVILLE(dot)STORTEK(dot)COM>
To: "'General - PGSQL'" <pgsql-general(at)postgresql(dot)org>
Cc: "'rob'" <robert(at)carolinecreager(dot)com>
Subject: plpgsql trigger on a cascaded delete
Date: 2001-03-16 23:35:14
Message-ID: 10FE17AD5F7ED31188CE002048406DE8514D16@lsv-msg06.stortek.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-03-16 23:47:40 Re: URL for gmake
Previous Message Mike Castle 2001-03-16 23:33:28 Re: URL for gmake