在函数中执行execute语句报如上的错误,脚本如下:
delimiter //
drop function if exists ClassType//
create function ClassType(v_dbid int) returns int
begin
declare Res numeric;
prepare stml from 'select t.type into Res from DBCATLOG t where t.dbid=?';
set @v_id:=v_dbid;
execute stml using @v_id;
drop prepare stml;
return Res;
end;
//
ERROR 1336 (0A000): Dynamic SQL is not allowed in stored function or trigger
mysql>
同时,如果我写一个关于insert的触发器,而且在触发器内部call 存储过程A,而A中也含有execute语句时,也会报这种错误?
请问,对于这种问题有什么直接或间接的解决方法吗?
delimiter //
drop function if exists ClassType//
create function ClassType(v_dbid int) returns int
begin
declare Res numeric;
prepare stml from 'select t.type into Res from DBCATLOG t where t.dbid=?';
set @v_id:=v_dbid;
execute stml using @v_id;
drop prepare stml;
return Res;
end;
//
ERROR 1336 (0A000): Dynamic SQL is not allowed in stored function or trigger
mysql>
同时,如果我写一个关于insert的触发器,而且在触发器内部call 存储过程A,而A中也含有execute语句时,也会报这种错误?
请问,对于这种问题有什么直接或间接的解决方法吗?
解决方案 »
- 有关光标的问题 !求助!!!
- limit SQL问题
- 单条记录出错的问题
- Commit exception overridden by rollback exception
- 这句为啥输入不进去呢?
- 怎么从excel表中导入数据
- 【请教】关于mysql设置了unique key被插入重复记录的疑惑
- 请教下,如何将一张表里面某个字段的排名存入另一个字段中
- centos7安装mysql后无法启动没有任何反应
- workbench导出数据报错 输入show variables like 'char%'显示这些信息,要怎么改?
- mysql有外键时分区出现错误Error Code : 1506
- 下面那个是mysql安装包
直接这么写 ,没必要动态
drop function if exists ClassType//
create function ClassType(v_dbid int) returns int
begin
declare Res numeric;
select t.type into Res from DBCATLOG t where t.dbid=v_dbid;
return Res;
end;
//