Home > Database > Mysql Tutorial > mysql存储过程错误调试记录_MySQL

mysql存储过程错误调试记录_MySQL

WBOY
Release: 2016-06-01 13:02:14
Original
1063 people have browsed it

mysql 存储过程错误调试记录 

公司平台在mysql数据库上运行,一些存储过程报错,调试过程痛苦,记录错误及解决办法,供参考。

调试环境:dbForge Studio for MySQL 6.1版本,试用版;

\

1、BIZ_GET_ORGAN_BY_CONDITION

问题1:提示递归调用错误,递归次数太多;根据业务设置,最大255;

SET@@max_sp_recursion_depth = 10;

常见如乱码造成导致条件失效,出现死循环;

问题2:变量的内容是乱码,数据库内容是中文,urt-8

declarevc_agency_type varchar(64) CHARACTER SET utf8;

定义变量时,需设置字符集;

问题3:存储过程参数传递中文,是乱码;定义参数同上;

2、BIZ_QUERY_USER_BY_CONDITION

问题1:row_count()返回-1

select 语句的返回值用FOUND_ROWS();row_count()一般是插入、修改、删除的影响行数;

问题2:mysql关于整数的除法

declare page_count int;

set page_count = 15 / 10 ;结果自动四舍五入为 2;

改用下面的语句:set page_count =FLOOR(result_count / page_size);

3、C3_BIZ_DATA_LIMIT

问题1:游标有记录,但是取值为空:游标语句中的变量不能和字段同名,且不要是关键字;

问题2:游标取不到值;

字段名称和变量名称一定不能相同;如果必须相同,给表加上别名进行区别;

问题3:out参数不能传值

修改成inout类型,存储过程共有三种类型:in out inout;

问题4:right函数改成subStr函数;

4、BIZ_CHANGER_ORG_PARENT_ID

问题1:mysql没有if not exists 语法,所以需要取总数,然后在判断行数量;

问题2:update不支持子查询问题;

update sys_org set leaftype = 1where id = (

selectorg_parent_id from sys_org where id = 变量

);

修改为:

update sys_org set leaftype = 1where id = (

select org_parent_id from

(select* from sys_org WHERE id = vc_source_id ) a

);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template