Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 错误代码:1815内部错误:JSON包装器:过程中出现意外类型_Mysql_Sql - Fatal编程技术网

Mysql 错误代码:1815内部错误:JSON包装器:过程中出现意外类型

Mysql 错误代码:1815内部错误:JSON包装器:过程中出现意外类型,mysql,sql,Mysql,Sql,这就是我写的程序 错误代码:1815内部错误:JSON包装器:意外类型 此查询中何时执行else case 但是当我将null改为{}时,它工作得很好 **SELECT CASE WHEN (select count(*) from user_attendance a where a.user_id =userId order by a.user_attn_id desc )!=0 then (select a.bays from user_attendance a where a.user_i

这就是我写的程序 错误代码:1815内部错误:JSON包装器:意外类型 此查询中何时执行else case 但是当我将null改为{}时,它工作得很好

**SELECT CASE
WHEN (select count(*) from user_attendance a where a.user_id =userId order by a.user_attn_id desc )!=0 then (select a.bays from user_attendance a where a.user_id =userId order by a.user_attn_id desc limit 1) ELSE null END) );**
当我单独运行它时,它也能正常工作

**insert into user_attendance(user_id,bays,modified_at,modified_by) values(16,(SELECT CASE
  WHEN (select count(*)  from user_attendance a where a.user_id =1 order by a.user_attn_id desc )!=0 then  (select a.bays  from user_attendance a where user_id =1 order by a.user_attn_id desc limit 1)
  ELSE null
END),now(),16);**
我不明白为什么它会表现出这种行为

DROP PROCEDURE `a`.`getTechnicianAttendance`;

DELIMITER $$

 CREATE PROCEDURE getTechnicianAttendance()
BEGIN
DECLARE users_count  INTEGER DEFAULT 0;
DECLARE finished INTEGER DEFAULT 0;

SELECT count(*) into users_count
FROM user_attendance
WHERE date = current_date();

IF users_count = 0 THEN

    Begin
    DECLARE userId INTEGER DEFAULT 0;
    DECLARE user_id_cursor CURSOR FOR
    select users.user_id from users left outer join user_roles on user_roles.user_id = users.user_id where user_roles.role_id = (select role_id from roles  where roles.role_name = 'Technician');

    DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;

    open  user_id_cursor;

    user_ids: LOOP
    FETCH user_id_cursor INTO userId;

    IF finished = 1 THEN
    LEAVE user_ids;
    END IF;

    insert into `autoscope`.`user_attendance` (user_id, 
      date,
      bays
       )   
    values (
      userId,
      current_date(),
           (SELECT CASE
   WHEN (select count(*)  from user_attendance a where a.user_id =userId order by a.user_attn_id desc )!=0 then   (select a.bays  from user_attendance a where a.user_id =userId order by a.user_attn_id desc limit 1)
   ELSE null
 END)
      );


     END LOOP user_ids;

    CLOSE user_id_cursor;
    End;
    END IF;
结束$$