Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: on ignore

  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,982
    Thanks
    120
    Thanked 76 Times in 76 Posts

    on ignore

    trigger: after insert into table1

    Code:
    insert ignore into table2
    Any chance to do something with records that were ignored (like putting them into another table), or I'm out of luck ?
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,720
    Thanks
    80
    Thanked 4,515 Times in 4,479 Posts
    I don't know a way to do it.

    But one easy way would be to use a Stored Procedure and forget about the trigger.

    In the Procedure, you would attempt the INSERT and, if you get an error from it, then do the other operation (e.g, put data into another table).

    I think triggers are over-used and stored procedures are under-used, especially with MySQL.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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