user1731603
user1731603

Reputation: 31

Trigger does not work

Good day all, I am trying to keep some historical test data if a certain field changes after every test. I have the data in a table called gypsum and wish to track changes in a table called history_gypsum. The trigger I have created shows errors which I do not understand,your help will be appreciated.Many thanks.G Styles

DELIMITER $$

CREATE TRIGGER `pattesti_testing`.`history_gypsum` 
 BEFORE UPDATE 
ON `pattesti_testing`.`gypsum`
FOR EACH ROW
BEGIN
IF OLD.leakage != NEW.leakage
    THEN
            INSERT INTO history_gypsum
                (
        id,
        register_number,
        equipment_description,
        make,
        class,
        location,
        continuity_value,
        insulation_value,
        leakage,
        polarity,
        test_frequency,
        date_of_test,
        comments,
        passed,
        tester_initials,
        next_test,
        current,
                )
                VALUES 
                (
        NEW.id,
        NEW.register_number,
        NEW.equipment_description,
        NEW.make,
        NEW.class,
        NEW.location,
        NEW.continuity_value,
        NEW.insulation_value,
        NEW.leakage,
        NEW.polarity,
        NEW.test_frequency,
        NEW.date_of_test,
        NEW.comments,
        NEW.passed,
        NEW.tester_initials,
        NEW.next_test,
        NEW.current,
                 );
    END IF ;
END;
 $$
DELIMITER ;

ERRORS

Query : CREATE TRIGGER `pattesti_testing`.`history_gypsum`  BEFORE        UPDATE      ON `pattesti_testing`.`gypsum`     FOR EACH ROW BEGIN    ...

Error Code : 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 ')
                VALUES 
                (
        NEW.id,
        NEW.register_n' at line 26

Execution Time : 00:00:00:000 Transfer Time : 00:00:00:000

Total Time : 00:00:00:000

Upvotes: 0

Views: 29

Answers (1)

fancyPants
fancyPants

Reputation: 51928

Remove the comma after current

   current, /*this comma is too much*/
                )
                VALUES 

Upvotes: 1

Related Questions