salix/db/routines/vn/procedures/packingListSwitch.sql

21 lines
483 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`packingListSwitch`(saleFk INT)
BEGIN
DECLARE valueFk INT;
DECLARE encajando INT DEFAULT 9;
SELECT isChecked INTO valueFk
FROM saleTracking
WHERE saleFk = saleFk
AND stateFk = encajando;
SET valueFk = (IFNULL(valueFk,0) + 1) MOD 3;
REPLACE saleTracking(saleFk, isChecked, workerFk, stateFk)
VALUES(saleFk,valueFk,account.myUser_getId(),encajando);
END$$
DELIMITER ;