。。。mysql给我的郁闷,也不是一次二次了,但我还是不习惯,继续吐血。
出现这个问题是在写一个存储过程中,用到游标时出现的,在网上查,说是mysql的一个bug( - -!这
都可以 )
找了一个多小时,最后终于找到解决的方案,就是在定义游标的下面,加上这句
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET P_ID = NULL;
存储过程如下
CREATE DEFINER = 'root'@'%'
PROCEDURE etm_one.P_ManagerWorkInfo(IN P_StartDate VARCHAR(255),
IN P_EndDate VARCHAR(255)
)
BEGIN
DECLARE P_ID INT;
DECLARE P_ParamName VARCHAR(50);
DECLARE P_strSql1, P_strSql2, P_strSql, P_strSql3 TEXT;
DECLARE curs CURSOR FOR
SELECT id
, paramname
FROM
K_SystemParam
WHERE
parentID = 26;
-- 解决mysql Bug:no data - zero rows fetched,selected,or processed
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET P_ID = NULL;
IF (ifnull(P_StartDate, '') = '') THEN
SET P_StartDate = '1900-01-01';
END IF;
IF (ifnull(P_EndDate, '') = '') THEN
SET P_EndDate = '2100-01-01';
ELSE
SET P_EndDate = date_format(date_add(P_EndDate, INTERVAL 1 DAY), '%Y-%m-d');
END IF;
SET P_strSql = '';
SET P_strSql1 = 'select CreatorGuid,createdate,';
SET P_strSql2 = 'select CreatorGuid,createdate,';
SET P_strSql3 = '';
OPEN curs;
FETCH curs INTO P_ID, P_ParamName;
WHILE (P_ID IS NOT NULL)
DO
SET P_strSql1 = concat(P_strSql1, 'ifnull(SUM(', P_ParamName, '),0)', P_ParamName, ',');
SET P_strSql2 = concat(P_strSql2, 'case when ID=', concat(P_ID, ''), ' then num end ',
P_ParamName, ',');
SET P_strSql3 = concat(P_strSql3, ',a.', P_ParamName);
FETCH curs INTO P_ID, P_ParamName;
END WHILE;
CLOSE curs;
/*SELECT P_strSql1;
SELECT P_strSql2;
--SELECT LEFT(P_strSql3,LEN(P_strSql3)-1)*/
SET P_strSql = concat(P_strSql1, '1 aa from (', P_strSql2, '1 aa from
(
select mi.CreatorGuid,date_format(mi.CreateTime,"%Y-%m-%d")
createdate,ks.ID,ks.ParamName,COUNT(*) num from MemberInteraction mi
left join K_SystemParam ks
on ks.id=mi.InteractionType
group by mi.CreatorGuid,ks.ParamName,ks.ID,date_format(mi.CreateTime,"%Y-%m-%d")
) a
)aa
group by CreatorGuid,createdate');
/*print P_strSql*/
SET P_strSql = concat('select km.RealName 顾问名称,d.DepartmentName 所属部
门,p.PositionName 职位,a.CreateDate 跟踪时间', P_strSql3, ' from (', P_strSql,
')a
left join K_Manager km
on a.CreatorGuid=km.ManagerGUID
left join Department d
on km.DepartmentGuid=d.DepartmentGuid
left join Position p
on km.PositionGuid=p.PositionGuid
',
' where a.createdate>="', P_StartDate, '" and a.createdate <"', P_EndDate, '"
order by km.RealName,a.createdate');
SET @P_strSql = P_strSql;
PREPARE result FROM @P_strSql;
EXECUTE result;
-- SELECT P_strSql;
END
分享到:
相关推荐
bootstrap-table-reorder-rows.js ,bootstraptable行拖动
BootStrapTable行内编辑;压缩包内包含行内编辑所需要的js+css; BootStrapTable行内编辑;压缩包内包含行内编辑所需要的js+css;
实现bootStarp Table ... { jsondata: JSON.stringify(newData) },//将整张表数据Post,当然,先序列化成Json function(data) { if (data == "success") { $table.bootstrapTable('refresh'); } }); } } });
bootstrap-table实现 行拖拽 插件 jquery.tablednd.js bootstrap-table-reorder-rows.js bootstrap-table-reorder-rows.css
15:33:05: [copy_file] begin copy file: FY_DATA_DIR4\FY_REC_DATA4.DAT => FY_DATA_DIR4\FY_REC_DATA_COPY.DAT 15:33:05: [copy_file] completed. 15:33:05: Copy file of Recover Tablespace: FY_REC_DATA_COPY...
Angular-ui-grid-draggable-rows.zip,HTML5拖放功能,用于Angular UI GridDragable Rows插件,用于UI Grid,Angularjs于2016年发布,是Angularjs的重写版。它专注于良好的移动开发、模块化和改进的依赖注入。angular...
fixed-data-table 是一个用于以灵活且强有力的方式建立并显示数据的 React 组件。它支持标准的桌面特征,像头条、行、列、头条组、滚动列。此组件在处理数千行数据的时不会牺牲性能。平滑地滚定是 FixedDataTable 的...
- Print selected rows or columns - Center partitions on printed sheet - Page numbering - Optimized DataGridViewTextBoxCell printing - Word wrapping and cell size as presented in the DataGridView ...
自定义较复杂的MKAnnotation,在弹出的Annotation上面显示多行的内容,每一行都是独立的、可选的,可以赋予不同的点击函数(callout function)。 注意:请在Mac下解压使用
npm install @langleyfoxall/react-dynamic-data-tableyarn add @langleyfoxall/react-dynamic-data-table 请记住在需要的地方导入DynamicDataTable组件。 import DynamicDataTable from "@langleyfoxall/react-...
- Changing most of Q3DScene properties affecting subviewports currently has no effect. - Widget based examples layout incorrectly in iOS. - Reparenting a graph to an item in another QQuickWindow is ...
1000 rows ( col { "id".rownumber }, col { "col title".name title }, col { "firstname".name firstname }, col { "surname".name surname }, col { "int".number between 10 and 1001 }, col { "money"....
Bootstrap 3 教程 10 - 行 以下视频教程的代码
'effectively zero.\nEither remove those points, or choose a ', ... 'distance other than ''cosine''.'], []); end % 标量化 Xnorm(:,ones(1,p))得到n*p的矩阵 X = X ./ Xnorm(:,ones(1,p)); case '...
14 rows selected. SQL> select ename as "emp name" ,sal+comm income from emp; emp name INCOME ---------- ---------- SMITH ALLEN 1900 WARD 1750 JONES MARTIN 2650 BLAKE CLARK SCOTT KING ...
自定义-Android-ListView-Rows-by-Subclassing 使用 RelativeLayout 的子类来替换持有者模式
dataMerge 对大量数据进行合并处理,优化性能。 主旨是对某一时间段里的数据进行合并,重复的记录进行去重,只取最新的记录。... callback:function(data,count,mergecount){ console.log(+new Da
我用它来修改ldf,你呢? XVI32 is a free hex-editor with the following main features: ...- No setup programm needed, doesn't write any data to registry - And last, but not least: XVI32 is free!
Laravel开发-laravel-grid 基本的Laravel数据网格系统,便于对大型表进行排序和过滤。不包含任何前端废话,所以外观是你的工作
Unity Vertex Animation Baker-Muilt-Rows 从这个项目修改: : 附加功能 烤的Muilt-Rows动画纹理。 添加填充像素以修复Muilt-Rows动画纹理“双线性”错误的像素采样。 使用MaterialPropertyBlock设置随机开始...