Re: Order of trigger execution: AFTER DELETE ON EACH ROW doesn't appear to be working properly

Поиск
Список
Период
Сортировка
От Christopher Maier
Тема Re: Order of trigger execution: AFTER DELETE ON EACH ROW doesn't appear to be working properly
Дата
Msg-id 1A429B71-3CE0-4AA9-B70B-B917EAEF6BE9@med.unc.edu
обсуждение исходный текст
Ответ на Re: Order of trigger execution: AFTER DELETE ON EACH ROW doesn't appear to be working properly  (aklaver@comcast.net (Adrian Klaver))
Список pgsql-sql
On Oct 13, 2008, at 3:08 PM, Adrian Klaver wrote:

> -------------- Original message ----------------------
> From: "Christopher Maier" <maier@med.unc.edu>
> <Snip>
>
>>
>> As you can see, doing a row-by-row delete works fine, but when  
>> doing a
>> bulk delete, all the before triggers are grouped together, as are all
>> the after triggers.
>>
>> Why are these calls not interleaved (e.g. BEFORE DELETE for record 1,
>> AFTER DELETE for record 1, BEFORE DELETE for record 2, AFTER DELETE
>> for record 2, etc.).  Is there any way I can get them to be
>> interleaved?  This causes problems for my application because if
>> dependent rows are not deleted immediately after the row that  
>> supports
>> it, then I can get "orphaned" rows left in the table that have no
>> supporting rows.
>>
>> Thanks,
>> Chris
>>
>
> Is not possible to delete the dependent rows from within the BEFORE  
> trigger?
>
> --
> Adrian Klaver
> aklaver@comcast.net

After playing around with it, yes, it is possible.  I've reworked my  
code to delete dependent rows before the row itself is deleted, and it  
works as desired.

Thanks,
Chris



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Scott Marlowe"
Дата:
Сообщение: Re: Updating Query of 1 table from data in another
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: EXISTS