Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. UPDATE invoices SET
  2. id = CONCAT (client,'-',
  3. order,
  4. IFNULL(variant,''),
  5. IF(subinvoice IS NULL, '',CONCAT('-',subinvoice))
  6. );
  7.  
  8. DELIMITER //
  9. DROP TRIGGER IF EXISTS invoice_generate_id//
  10. CREATE TRIGGER invoice_generate_id
  11. BEFORE INSERT ON invoices
  12. FOR EACH ROW
  13. BEGIN
  14. NEW.id = CONCAT (client,'-',
  15. order,
  16. IF (variant IS NOT NULL) THEN
  17. variant
  18. ELSE ''
  19. END IF;
  20. ,
  21. IF (subinvoice IS NOT NULL) THEN
  22. CONCAT('-',subinvoice))
  23. ELSE ''
  24. END IF;
  25. );
  26. END//
  27. DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement