Search Postgresql Archives

Re: Which record causes referential integrity violation on delete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Andrus" <noeetasoftspam@xxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux