Advertisement
vallec

Untitled

Apr 17th, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. /* zadachi */
  2.  
  3. DELIMITER |
  4.  
  5. CREATE TRIGGER salarypayments_delete_trigger
  6. AFTER DELETE ON salarypayments
  7. FOR EACH ROW
  8. BEGIN
  9. INSERT INTO salarypayments_log (
  10. operation,
  11. old_coach_id,
  12. old_month,
  13. old_year,
  14. old_salaryAmount,
  15. old_dateOfPayment,
  16. dateOfLog
  17. ) VALUES (
  18. 'DELETE',
  19. OLD.coach_id,
  20. OLD.month,
  21. OLD.year,
  22. OLD.salaryAmount,
  23. OLD.dateOfPayment,
  24. NOW()
  25. );
  26. END;
  27. |
  28.  
  29. DELIMITER ;
  30.  
  31. DELETE FROM salarypayments WHERE id = 1;
  32.  
  33. /* 2 */
  34. DELETE FROM salarypayments WHERE 1 = 1;
  35.  
  36. INSERT INTO salarypayments (coach_id, month, year, salaryAmount, dateOfPayment)
  37. SELECT old_coach_id, old_month, old_year, old_salaryAmount, old_dateOfPayment
  38. FROM salarypayments_log
  39. WHERE operation = 'DELETE';
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement