Results 1 to 1 of 1

Thread: trigger issue

  1. #1
    Join Date
    Apr 2012
    Posts
    6

    Unanswered: trigger issue

    hi I have created a trigger:

    Code:
    CREATE TRIGGER delete_accident_table BEFORE DELETE ON accident
    FOR EACH ROW
    BEGIN
    INSERT INTO archive 
    Select old.AccidentID,old.AccidentDtm,old.AccidentNotes,old.Street,old.City,old.State,old.Zip,old.DriverID,old.WitnessID,now();
    END
    but it throws me error:

    Error

    SQL query: Documentation

    CREATE TRIGGER delete_accident_table BEFORE DELETE ON accident FOR EACH ROW BEGIN INSERT INTO archive
    SELECT old.AccidentID, old.AccidentDtm, old.AccidentNotes, old.Street, old.City, old.State, old.Zip, old.DriverID, old.WitnessID, now( ) ;

    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5

    do you know what could be wrong?


    Also I have one more trigger for setting mode:

    Code:
    CREATE TRIGGER updtrigger BEFORE UPDATE ON claiminfo
    FOR EACH ROW
    BEGIN
    IF NEW.Mode != 'ABW' THEN
    SET NEW.Mode='ABW';
    ELSEIF NEW.Mode='GHU' THEN
    SET NEW.Mode='TUH';
    END IF;
    END
    I am getting here:

    SQL query:

    CREATE TRIGGER updtrigger BEFORE UPDATE ON claiminfo FOR EACH ROW BEGIN IF NEW.Mode != 'ABW' THEN SET NEW.Mode = 'ABW';

    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5

    not too sure what is wrong here ;]


    OK it was missing word delimiter... i have resolved this one
    Last edited by exose; 04-25-12 at 11:21. Reason: resolved

Posting Permissions

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