create procedure temp (in empId int)
begin
declare emptype varchar;
select emptype = qoute(emptype) from dms_document where id = empid;
select emptype
case
when emptype = 'P' then
select doctype from dms_report where pilot = 1
else
select 'No Documents required'
end case
end;
这是我的查询,我正在 MySQL 中创建过程,我在 case 语句中遇到错误,请帮助我为什么会出现此错误如何声明 case 语句为什么在创建过程的工作台中出现错误
最佳答案
你漏掉了逗号。
CREATE PROCEDURE temp (IN empId INT)
BEGIN
DECLARE emptype VARCHAR;
SELECT emptype = qoute(emptype) FROM dms_document WHERE id = empid;
SELECT emptype,
CASE
WHEN emptype = 'P' THEN doctype;
ELSE 'No Documents required';
END CASE ;
FROM dms_report WHERE pilot = 1
End;
关于mysql - mysql创建过程时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31072717/