我有一些Node-Red流作爲正在處理的Web應用程序的REST接口。但是,我在MySQL上遇到了插入事務。使用節點紅插入事務期間的ER_PARSE_ERROR
查詢被送入MySQL的節點是:
START TRANSACTION;
INSERT INTO `light_schedule` (`name`, `light_pwm`,
`accent_pwm_red`, `accent_pwm_green`, `accent_pwm_blue`, `strobe`,
`start_date`, `start_time`, `end_date`, `end_time`, `repeat_type`,
`repeat_every`, `repeat_sunday`, `repeat_monday`, `repeat_tuesday`,
`repeat_wednesday`, `repeat_thursday`, `repeat_friday`, `repeat_saturday`,
`repeat_by`, `end_after_num`, `end_on`, `is_template`)
VALUES ('example', NULL, NULL, NULL, NULL, 1, '2016-4-1', NULL, NULL, NULL, 2, 1, 1, 1, 1,
1, 1, 1, 1, NULL, NULL, NULL, 0);
SET @schedule = LAST_INSERT_ID();
INSERT INTO `strobe_colors` (`schedule_id`, `order_index`,
`duration`, `accent_pwm_red`, `accent_pwm_green`, `accent_pwm_blue`,
`rainbow`)
VALUES (@schedule, 0, 4600, NULL, NULL, NULL, 1),
(@schedule, 1, 4100, 150, 200, 163, 0);
INSERT INTO `lights_schedules` (`light_id`, `schedule_id`)
VALUES (5, @schedule),
(6, @schedule);
COMMIT;
此查詢工作完美,如果我複製並粘貼到phpMyAdmin的的查詢窗口。然而,當我試圖通過我的流程的觸發它,我得到一個錯誤:
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO
`light_schedule` (`name`, `light_pwm`, `accent_pwm_red`, `accent_pw' at line 2
我一直無法就這個錯誤非常多的進步。我找到的最有幫助的事情是建議,以確保我對所有列和表名稱有反駁意見,這些我都無濟於事。
嘗試用單引號代替反引號 – hardillb
@hardillb,剛試過,不幸的是沒有喜悅。 –