Мне нужно создать такую процедуру, но я получаю ошибки, которые я решаю, просто удаляя BEGIN и END в других процедурах, но у этой операции есть TRANSACTION, и я не могу найти решение.
CREATE PROCEDURE sp_device_post_device_status (IN deviceID int(11), IN zone int(11), IN stat int(11))
BEGIN
START TRANSACTION
UPDATE device_statuses
SET is_last_one = 0
WHERE id_device = deviceID
AND is_last_one = 1
AND zoneNo = zone;
INSERT INTO device_statuses (id_device, zoneNo, status, is_last_one)
VALUES (deviceID, zone, stat, 1);
commit
END;
она возвращает :
SQL query: Copy
CREATE PROCEDURE sp_device_post_device_status (IN deviceID int(11), IN zone int(11), IN stat int(11))
BEGIN
START TRANSACTION
UPDATE device_statuses
SET is_last_one = 0
WHERE id_device = deviceID
AND is_last_one = 1
AND zoneNo = zone
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE device_statuses
SET is_last_one = 0
WHERE id_device = deviceID
' at line 4