获取错误“ERROR 1064(42000):您的SQL语法出错;请查看与您的MySQL服务器版本对应的手册,以便在正确的语法附近使用')”
我在编码中找不到任何错误的语法,但仍然无法找到问题,
CREATE PROCEDURE sp_GetAssignTask(IN module varchar(100),IN did int,IN actstatus int,IN act varchar(30),IN sdate datetime,IN edate datetime,OUT outmsg varchar(20))
BEGIN
DECLARE DateDuration int;
SET DateDuration = SELECT DATEDIFF(edate, sdate) ;
insert into sch_taskassigned (Duration,Module,Content,Deptid,taskenddate,taskstartdate,activestatus,activity,subactivity)values (DateDuration,modul,conte,did,edate,sdate,actstatus,act,subact);
set outmsg = 'Added Successfully';
END
答案 0 :(得分:1)
我能看到的唯一语法问题是
SET DateDuration = (SELECT DATEDIFF(edate, sdate));
通知我在等于之后添加了()。
另外,根据您执行此操作的客户端,您可能需要更改分隔符,例如:
DELIMITER $$
CREATE PROCEDURE sp_GetAssignTask(IN module varchar(100),IN did int,IN actstatus int,IN act varchar(30),IN sdate datetime,IN edate datetime,OUT outmsg varchar(20))
BEGIN
DECLARE DateDuration int;
SET DateDuration = (SELECT DATEDIFF(edate, sdate));
insert into sch_taskassigned (Duration,Module,Content,Deptid,taskenddate,taskstartdate,activestatus,activity,subactivity)values (DateDuration,modul,conte,did,edate,sdate,actstatus,act,subact);
set outmsg = 'Added Successfully';
END
$$