| От | Jeff Davis |
|---|---|
| Тема | Re: Returning NEW in an on-delete trigger |
| Дата | |
| Msg-id | 1221764432.6194.254.camel@dell.linuxdev.us.dell.com обсуждение исходный текст |
| Ответ на | Returning NEW in an on-delete trigger ("Michael Nolan" <htfoot@gmail.com>) |
| Список | pgsql-general |
On Thu, 2008-09-18 at 14:21 -0400, Michael Nolan wrote:
> Recently I discovered a coding error of mine in a trigger that is
> called only for deletes.
>
> I was returning NEW instead of OLD.
>
> Since NEW is undefined when deleting a row, it was failing and the row
> wasn't being deleted.
In PL/pgSQL, NEW is NULL for BEFORE DELETE triggers. It doesn't appear
to be obviously documented that this is the case (which is, I assume,
why you said it is undefined), and I agree that it can cause confusion.
> However, it was failing silently. Shouldn't this have recorded an
> error or warning somewhere?
This is a feature, not a bug. Sometimes you don't want to delete a
record, and returning NULL is the way to do that.
Regards,
Jeff Davis
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера