有谁知道为什么我在下面不断收到此错误?我似乎无法动摇它。
call test_delete('WOW@GMAIL.COM', '''2c016cd6-87e6-11e1-9fac-001cd4565d26''', 0) Error Code: 1064. 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 'UPDATE user u SET u.enable = ? WHERE u.' at line 2
DELIMITER $$
CREATE PROCEDURE `test_delete`(
IN username NVARCHAR(255),
IN district_admin_ids LONGTEXT,
IN active BIT(1)
)
BEGIN
SET @username = username;
SET @district_admin_ids = district_admin_ids;
SET @active = CASE WHEN active > 0 THEN 1 ELSE 0 END;
SET @query = CONCAT('
SET SQL_SAFE_UPDATES=0;
UPDATE user u
SET u.enable = ?
WHERE u.id IN (
SELECT da.id
FROM test da
WHERE u.id = da.id
AND u.username = ?
AND da.id IN (?)
);');
PREPARE statement FROM @query;
EXECUTE statement USING @active, @username, @district_admin_ids;
DEALLOCATE PREPARE statement;
END