1583 - Incorrect parameters in the call to native function 'IFNULL'
DECLARE p_substoreid NVARCHAR(100);
DECLARE p_Fname NVARCHAR(100);
DECLARE p_name NVARCHAR(100);
DECLARE no_more_departments INTEGER DEFAULT 0;
DECLARE Cursor__bigclass CURSOR FOR SELECT `name` FROM Tempdb__bigclass;
DECLARE Cursor_thedate CURSOR FOR SELECT substoreid,Fname FROM Tempdb__thedate;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET no_more_departments=1;
DROP TEMPORARY TABLE IF EXISTS Tempdb__hdnames;
DROP TEMPORARY TABLE IF EXISTS Tempdb__receive_report;
DROP TEMPORARY TABLE IF EXISTS Tempdb__thedate;
DROP TEMPORARY TABLE IF EXISTS Tempdb__tab;
DROP TEMPORARY TABLE IF EXISTS Tempdb__bigclass;
SET @v_sql= CONCAT('Create TEMPORARY Table Tempdb__hdnames(select substoreid as `name` from hotelid where substoreid in (', p_FdName,'))');
PREPARE stmt FROM @v_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @v_sql= CONCAT('Create TEMPORARY Table Tempdb__bigclass(SELECT id as `name` FROM home_class GROUP BY `id` )');
PREPARE stmt FROM @v_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
CREATE TEMPORARY TABLE Tempdb__receive_report(
SELECT A.* , B.bname AS Fname FROM receive_report A
LEFT JOIN hotelid B ON A.substoreid=B.substoreid
WHERE A.the_date BETWEEN p_StarDate AND p_EndDate
AND A.substoreid IN (SELECT `name` FROM Tempdb__hdnames)
AND (A.name='房型统计' OR A.name='房类'));
CREATE TEMPORARY TABLE Tempdb__thedate (SELECT substoreid,Fname FROM Tempdb__receive_report GROUP BY substoreid, Fname);
SET @tab_sql='Create TEMPORARY Table Tempdb__tab(rq NVARCHAR(100),Fname NVARCHAR(100),hjzfs FLOAT,hjczs FLOAT,hjzj FLOAT';
SET @where_sql = '';
SET @column_sql = '';
SET @select_column_sql = '';
OPEN Cursor__bigclass;
REPEAT
FETCH Cursor__bigclass INTO p_name;
BEGIN
IF NOT no_more_departments THEN
SET @tab_sql= CONCAT(@tab_sql,',`C', p_name,'Czfs` FLOAT',',`C', p_name,'Cczs` FLOAT',',`C', p_name,'Czj` FLOAT');
SET @column_sql = CONCAT(@column_sql,',`C', p_name,'Czfs`',',`C', p_name,'Cczs`',',`C', p_name,'Czj`');
SET @where_sql = CONCAT(@where_sql,',IFNULL(SUM(CASE WHEN (id =''',p_name,''' and `name`=''房型统计'') THEN day_rooms END) ,0)'
,',IFNULL(SUM(CASE WHEN (id =''',p_name,''' and `name`=''房类'') THEN day_rooms END) ,0)'
,',IFNULL(SUM(CASE WHEN (id =''',p_name,''' and `name`=''房类'') THEN day_money END) ,0)');
SET @select_column_sql = CONCAT(@select_column_sql,'
, IFNULL(C',p_name,'Czfs,0) as C',p_name,'Czfs, IFNULL(C',p_name,'Cczs,0) as C',p_name,'Cczs, IFNULL(C',p_name,'Czj,0) as C',p_name,'Czj
,CASE IFNULL(C',p_name,'Czfs,0) WHEN 0 THEN 0 ELSE IFNULL(C',p_name,'Cczs,0)/C',p_name,'Czfs END AS C',p_name,'Cczl
,CASE IFNULL(C',p_name,'Cczs,0) WHEN 0 THEN 0 ELSE IFNULL(C',p_name,'Czj,0)/C',p_name,'Cczs END AS C',p_name,'Cpjfj');
END IF;
END;
UNTIL no_more_departments END REPEAT;
CLOSE Cursor__bigclass;
SET @tab_sql= CONCAT(@tab_sql,');');
PREPARE stmt FROM @tab_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET no_more_departments = 0;
OPEN Cursor_thedate;
REPEAT
FETCH Cursor_thedate INTO p_substoreid,p_Fname;
BEGIN
IF NOT no_more_departments THEN
SET @execute_sql= CONCAT('INSERT INTO Tempdb__tab(rq,Fname,hjzfs,hjczs,hjzj'
,@column_sql,') SELECT ''',IFNULL(p_substoreid,''),''',''',IFNULL(p_Fname,''),'''
,IFNULL(SUM(CASE WHEN (id =''总房数'' and `name`=''房型统计'') THEN day_rooms END),0)
,IFNULL(SUM(CASE WHEN (id =''合计'' and `name`=''房类'') THEN day_rooms END),0)
,IFNULL(SUM(CASE WHEN (id =''合计'' and `name`=''房类'') THEN day_money END),0)'
,@where_sql,'
FROM Tempdb__receive_report WHERE substoreid=',p_substoreid,';');
PREPARE stmt FROM @execute_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END IF;
END;
UNTIL no_more_departments END REPEAT;
CLOSE Cursor_thedate;
SET @execute_sql= CONCAT('SELECT rq,Fname,hjzfs,hjczs,hjzj
,CASE IFNULL(hjzfs,0) WHEN 0 THEN 0 ELSE IFNULL(hjczs,0)/hjzfs END AS hjczl
,CASE IFNULL(hjczs,0) WHEN 0 THEN 0 ELSE IFNULL(hjzj,0)/hjczs END AS hjpjfj'
,@select_column_sql,' FROM Tempdb__tab ORDER BY rq;');
PREPARE stmt FROM @execute_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
存储过程报错,求助,急急急!!!
MYSQL : 1583 'IFNULL'
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- jasondyoung 2017-10-19 08:57关注
Incorrect parameters in the call to native function 'IFNULL'
你检查用这个函数的参数,它说这个参数不正确,具体程序里,你看看这个参数值是不是有问题,不是字符串或者null本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 (标签-STM32|关键词-智能小车)
- ¥20 关于#stm32#的问题,请各位专家解答!
- ¥15 (标签-python)
- ¥15 第一个已完成,求第二个做法
- ¥20 搭建awx,试了很多版本都有错
- ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
- ¥15 activiti工作流问题,求解答
- ¥15 有人写过RPA后台管理系统么?
- ¥15 Bioage计算生物学年龄
- ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?