我在MYSQL中调用此过程时收到错误1318。我在这个存储过程中做错了什么?我甚至被允许做这样的事情吗?
CREATE DEFINER=`root`@`localhost` PROCEDURE `CN_renumber`
(
OUT @maxCn,
OUT param1 INT,
OUT update_count INT
)
BEGIN
DECLARE sql_error TINYINT DEFAULT FALSE;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET sql_error = TRUE;
START TRANSACTION;
/*Renumber Cn in DBO*/
/* Set max cn and incremented afterwords */
SET @maxCn = '23206';
UPDATE dbo.billadr SET Cn = (@maxCn:=@maxCn + 1);
IF sql_error = FALSE THEN SET update_count = 1;
COMMIT;
ELSE
SET update_count = 0;
ROLLBACK;
END IF;
END
答案 0 :(得分:0)
参数有问题。尝试此过程,它将修复错误1318 -
CREATE DEFINER='root'@'localhost' PROCEDURE CN_renumber
(OUT maxCn int, OUT param1 int, OUT update_count int)
BEGIN
SET @maxCn = 23206;
UPDATE billadr SET Cn = (@maxCn := @maxCn + 1);
SET maxCn = @maxCn;
END
用法示例 -
SET @maxCn = NULL;
SET @param1 = NULL;
SET @update_count = NULL;
CALL CN_renumber(@maxCn, @param1, @update_count);
SELECT @maxCn, @param1, @update_count;