From: | "Simon Kinsella" <simon(at)bluefiresystems(dot)co(dot)uk> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Help with trigger that updates a row prior to a potentially aborted deletion? |
Date: | 2006-03-01 13:30:23 |
Message-ID: | 20060301133041.8EFFA19B797@smtp03l.fasthosts.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi all,
I have a situation where a DELETE operation may (correctly) fail due to a
RESTRICT FK constraint. If so, I need to set a flag in the row indicating
that it has been marked for deletion so that I can disregarded in subsequent
queries.
I'm trying to achieve this with a BEFORE DELETE trigger, which would set the
'marked_for_deletion' field to TRUE before attempting the delete proper.
Then if the DELETE fails the row would still be tagged and I'd be happy.
Problem is, when the DELETE operation fails with a RESTRICT VIOLATION error
the entire operation is rolled back, including the BEFORE triggers, leaving
me back where I started.
Is there anyway to get the DELETE operation, or more specifically the FK
constraint, to fail silently, i.e. to skip over the failed operation and not
throw an exception? I'm really racking my brains on this one but not really
getting anywhere!
I have sample data defs to play with if that would be helpful.
Thanks in advance!
Simon Kinsella
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2006-03-01 13:49:02 | Re: [SQL] regarding grant option |
Previous Message | A. Kretschmer | 2006-03-01 11:33:01 | Re: Index to support LIKE '%suffix' queries |