Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2008
    Posts
    4

    Unanswered: Problem of "Instead of Delete" Trigger

    How Can I check that , data in the table which i have to delete is related to the other table,

  2. #2
    Join Date
    Mar 2008
    Posts
    4
    HI Rakesh plz tell me detail

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Are you sure you want an instead of trigger or should you be looking at cascading relationships?
    George
    Home | Blog

  4. #4
    Join Date
    Mar 2008
    Posts
    4
    Quote Originally Posted by georgev
    Are you sure you want an instead of trigger or should you be looking at cascading relationships?
    Yes , I want to show msg " You can't delete record because it is related to other table/ data" befor system msg

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    By default trying to delete from a table with child records (you mean child records right - not parent records?). Will result in an error. Just have the application trap the error and report your custom message.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Quote Originally Posted by pootle flump
    By default trying to delete from a table with child records (you mean child records right - not parent records?). Will result in an error. Just have the application trap the error and report your custom message.
    only if rakeeh has some referential integrity declared.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Thrasymachus
    only if rakeeh has some referential integrity declared.
    Ah of course - advanced relational theory
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    if he is handling things like this in INSTEAD OF DELETE triggers, I would not make any assumptions.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I agree with the other psoters; if you have proper referential integrity applied then trying to delete a parent without first removing the children will throw an error.

    CASCASE allows you to decide how to handle such scenarios. For example, you can set it so that when you delete the parent you can delete all the related child records; leaving no orphans.
    Bear in mind that when you have delete cascade relationships, it will delete without error; meaning you should be sure you want to delete before you do so!
    George
    Home | Blog

Posting Permissions

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