我需要一种程序,以核实某一数字是否属首要。 The syntax on the syntax似乎是罚款的,但有以下错误:
Query : CREATE PROCEDURE prime_ number (IN n INT) BEGIN SET @prime = “Prime number”; SET @n_prime = “Not prime number”; SET @divider = ......
《刑法》:1064
您在座椅上有一处错误;检查了与MySQL服务器版本相对应的手册,供右yn在28行附近使用。
Here s my code so far:
DELIMITER $
CREATE PROCEDURE prime_number(IN n INT)
BEGIN
SET @prime = "Prime number";
SET @n_prime = "Not prime number";
SET @divider = 0;
SET @i = 5;
IF n % 2 = 0 THEN
SELECT @n_prime;
ELSEIF (n < 2) OR ((n % 3) = 0) THEN /* Was using ELSE IF, separatedly*/
SELECT @n_prime;
ELSE
SET @root = SQRT(n);
WHILE @i <= @root && @divider = 0 DO
IF (n % @i) = 0 THEN
SET @divider = 1;
END IF;
SET @i = @i + 1;
END WHILE;
IF @divider = 1 THEN SELECT @n_prime;
ELSE SELECT @prime;
END IF;
END IF; /*Line 28*/
END $
DELIMITER ;
它为什么会发生?