Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009
    Posts
    6

    Unanswered: Cascade delete in self referenced table

    Is it possible to have a delete rule if the table has "same table reference constraint"?

    When I try to delete a category from from categories table, I get:
    "The delete statement conflicted with the same table reference constraint."

    ...that happens if there are subcategories that have idParCat that reference the parent category being deleted.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I think you can only handle this with a trigger (assuming you want to submit a single delete query and have the cascade handled automatically). I haven't got SQL available to me right now so can't test. You don't actually want to cascade delete though right - you want to set all categories that reference the deleted category to null?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2009
    Posts
    6
    Quote Originally Posted by pootle flump View Post
    I think you can only handle this with a trigger (assuming you want to submit a single delete query and have the cascade handled automatically). I haven't got SQL available to me right now so can't test.
    I will look into this option, any trigger samples you can provide?

    Quote Originally Posted by pootle flump View Post
    You don't actually want to cascade delete though right - you want to set all categories that reference the deleted category to null?
    I'm not sure how that would coexist with current data, since idParentCategory is already set to NULL for top level categories...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •