我已经查看了有关此问题的其他问题。它不工作。
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `environment_admin`(
IN environment_id TEXT,
IN user_id TEXT,
IN username VARCHAR(75),
IN password VARCHAR(512)
)
BEGIN
DECLARE env_id INT;
DECLARE admin_id INT;
SET env_id = CAST(environment_id AS SIGNED INT);
SET admin_id = CAST(user_id AS SIGNED INT);
IF NOT EXISTS(SELECT 1 FROM `environment`.`environment_accounts` WHERE environment_id = env_id AND user_id = admin_id) THEN
BEGIN
INSERT INTO
`environment`.`environment_accounts`
(
`environment_id`,
`user_id`,
`username`,
`password`,
`is_active`,
`is_admin`,
`is_mod`
)
VALUES
(
env_id,
admin_id,
username,
password,
1,
1,
1
);
END;
END IF;
END
所以如果我运行:
CALL `environment`.`environment_admin`('22','1','kacieh','512c9ad228332bbd30d09ce7ffb8896e00a1610e914a5fa180bf15ce702b90423e6a9540579f672315ae3c6cb1b8d06ee2b784b4761e806675aa88c2a915553e');
我得到 0 行影响,果然,什么也没发生。-_- 这几个小时我一直在工作,我测试了条件查询,它有效。我只测试了存储过程中的插入语句,它也可以工作。