mysql - mysql创建过程时出错

标签 mysql stored-procedures

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/

相关文章:

mysql - Like 中的子查询字段

带参数语法的 MySQL 过程

mysql - PHPMyadmin 函数/存储过程消失

mysql - Rails 保持数据库连接时间过长,无法运行存储过程

javascript - 使用 Javascript 更改表值

mysql - 如果否则更新 sql 查询以组合多个查询

mysql - 一条sql语句的结果有问题

php - 将 MYSQL 表数据传递到 HTML

java - SQL Server 存储过程和 jdbc

MySQL 存储过程语法