Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread How to delete orphaned detail records
Thu, Nov 13 2008 8:33 PMPermanent Link

Darrell
Hi ~

how can I delete orphaned detail records, e.g. invoice detail records for which the
invoice header record has been deleted?
These records are linked via the invoice_id field.

Thanks
Darrell
Thu, Nov 13 2008 9:43 PMPermanent Link

"Robert"

"Darrell" <darrell.funk@the_funks.ca> wrote in message
news:3D2AA825-168E-49AF-8F39-2C930AE0714A@news.elevatesoft.com...
> Hi ~
>
> how can I delete orphaned detail records, e.g. invoice detail records for
> which the
> invoice header record has been deleted?
> These records are linked via the invoice_id field.
>

select  invoice_id, master_id
from details
left outer join master on master_id = invoice_id
where master_id = null

gives you the orphans. Use that as the subquery for your deletes.

Robert


Thu, Nov 13 2008 9:46 PMPermanent Link

Darrell
Thanks!
Image