mysql 总报错 Error Code : 1064 请高手指点
我是个新手 找了一下午错误了 头大了 请高手指点 到底是哪里错了。。
DELIMITER $$
CREATE PROCEDURE `pr_addshieldstateparam`(
IN mobile VARCHAR(60),
IN sendNo VARCHAR(60),
IN reason VARCHAR(200),
IN jobNumber VARCHAR(60))
BEGIN
DECLARE resultCode VARCHAR(2);
-- DECLARE resultDesc VARCHAR(500);
SET autocommit = 0;
IF sendNo IS NULL THEN
SET sendNo='';
END IF;
IF reason IS NULL THEN
SET reason='';
END IF;
IF sendNo='' THEN
SELECT -1 AS resultCode;
ELSEIF
INSERT INTO shieldstate(mobile,sendno,reason,jobnumber)
VALUES (mobile,sendNo,reason,jobNumber);
INSERT INTO shieldstate_log(mobile,sendno,reason,jobnumber,operation)
VALUES (mobile,sendNo,reason,jobNumber,'0');
IF @@warning_count <> 0 ||@@error_count>0
THEN
ROLLBACK;
SELECT -2 AS resultCode;
ELSE
COMMIT;
SELECT 0 AS resultCode;
END IF;
END IF;
END$$
DELIMITER ;
报错信息:
Query : CREATE PROCEDURE `pr_addshieldstateparam`( IN mobile varchar(60), in sendNo varchar(60), in reason varchar(200), in jobNumber v...
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 'into shieldstate(mobile,sendno,reason,jobnumber)
values (mobile,sendNo,reason,' at line 19
------解决方案--------------------DELIMITER $$
CREATE PROCEDURE `pr_addshieldstateparam`(
IN mobile VARCHAR(60),
IN sendNo VARCHAR(60),
IN reason VARCHAR(200),
IN jobNumber VARCHAR(60))
BEGIN
DECLARE resultCode VARCHAR(2);
-- DECLARE resultDesc VARCHAR(500);
SET autocommit = 0;
IF sendNo IS NULL THEN
SET sendNo='';
END IF;
IF reason IS NULL THEN
SET reason='';
END IF;
IF sendNo='' THEN
SET resultCode=-1 ;
ELSE
INSERT INTO shieldstate(mobile,sendno,reason,jobnumber)
VALUES (mobile,sendNo,reason,jobNumber);
INSERT INTO shieldstate_log(mobile,sendno,reason,jobnumber,operation)
VALUES (mobile,sendNo,reason,jobNumber,'0');
END IF;
IF @@warning_count <> 0 AND @@error_count>0 THEN
ROLLBACK;
SELECT -2 AS resultCode;
ELSE
COMMIT;
SELECT 0 AS resultCode;
END IF;
-- END IF;
END$$
DELIMITER ;
------解决方案--------------------逻辑判断自行检查一下
------解决方案--------------------IF @@warning_count <> 0 or @@error_count>0
------解决方案--------------------IF sendNo='' THEN
SELECT -1 AS resultCode;
ELSE
INSERT INTO shieldstate(mobile,sendno,reason,jobnumber)
VALUES (mobile,sendNo,reason,jobNumber);
INSERT INTO shieldstate_log(mobile,sendno,reason,jobnumber,operation)
VALUES (mobile,sendNo,reason,jobNumber,'0');
ELSEIF的语法不是这样。