Re: Which record causes referential integrity violation on delete
В списке pgsql-general по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Which record causes referential integrity violation on delete |
| Дата | |
| Msg-id | 12340.1120322209@sss.pgh.pa.us обсуждение |
| Ответ на | Which record causes referential integrity violation on delete ("Andrus" <noeetasoftspam@online.ee>) |
| Список | pgsql-general |
"Andrus" <noeetasoftspam@online.ee> writes:
> ERROR: update or delete on "customer" violates foreign key constraint
> "invoice_customer_fkey" on "invoice"'
> How to determine the primary key of invoice table which causes this error
> in generic way ?
There is no generic way to do that, because the question makes an
assumption that isn't generic; in fact two of them. One, that there
is only one row of invoice referencing this customer row; and two,
that invoice even has a primary key, which is certainly not implied
by the existence of an FK reference to customer.
If your intention is to perform some generic action like deleting all
the referencing rows, you may well find that marking the foreign key
reference ON DELETE CASCADE (or one of the other available options)
would solve the problem without needing to add any client-side logic.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера