Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* zadachi */
- DELIMITER |
- CREATE TRIGGER salarypayments_delete_trigger
- AFTER DELETE ON salarypayments
- FOR EACH ROW
- BEGIN
- INSERT INTO salarypayments_log (
- operation,
- old_coach_id,
- old_month,
- old_year,
- old_salaryAmount,
- old_dateOfPayment,
- dateOfLog
- ) VALUES (
- 'DELETE',
- OLD.coach_id,
- OLD.month,
- OLD.year,
- OLD.salaryAmount,
- OLD.dateOfPayment,
- NOW()
- );
- END;
- |
- DELIMITER ;
- DELETE FROM salarypayments WHERE id = 1;
- /* 2 */
- DELETE FROM salarypayments WHERE 1 = 1;
- INSERT INTO salarypayments (coach_id, month, year, salaryAmount, dateOfPayment)
- SELECT old_coach_id, old_month, old_year, old_salaryAmount, old_dateOfPayment
- FROM salarypayments_log
- WHERE operation = 'DELETE';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement