Error Code: 1062. Duplicate entry '1' for key 'PRIMARY'

后端 未结 8 2187
既然无缘
既然无缘 2020-12-01 03:55

I have a problem on this error message, when i try this:

INSERT INTO `PROGETTO`.`UFFICIO-INFORMAZIONI` (`ID`, `viale`, `num_civico`,  
`data_apertura`, `data         


        
8条回答
  •  孤城傲影
    2020-12-01 04:06

    Also check your triggers.

    Encountered this with a history table trigger which tried to insert the main table id into the history table id instead of the correct hist-table.source_id column.

    The update statement did not touch the id column at all so took some time to find:

    UPDATE source_table SET status = 0;
    

    The trigger tried to do something similar to this:

    FOR EACH ROW
    BEGIN
        INSERT INTO `history_table` (`action`,`id`,`status`,`time_created`)
        VALUES('update', NEW.id, NEW.status, NEW.time_created);
    END;
    

    Was corrected to something like this:

    FOR EACH ROW
    BEGIN
        INSERT INTO `history_table` (`action`,`source_id`,`status`,`time_created`)
        VALUES('update', NEW.id, NEW.status, NEW.time_created);
    END;
    

提交回复
热议问题