首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql存储过程能动态定义光标吗?解决方法

2012-09-10 
mysql存储过程能动态定义光标吗?create procedure repairChild(in uid int, in type_get char(6))begindec

mysql存储过程能动态定义光标吗?
create procedure repairChild(in uid int, in type_get char(6))
begin
declare userCusor cursor for select uid from by_users……
if uid = 0 then
……
else
……
end if;
end
我需要根据传进来的uid生成userCusor光标,可是mysql declare语句必须放在开头,有什么办法实现吗?

[解决办法]
对 只能放在开头
有什么需求必须放在后面吗
[解决办法]
不可以动态定义,但可以使用变量。这个变量会跟着变化。 关闭然后再OPEN一下就行。
[解决办法]
不能动态定义的,但可使用变量。
变量会随着变化的。
[解决办法]
不能动态定义游标,间接方法

declare userCusor cursor for select uid from lsb
....
create table lsb as select * from by_users where id=uid
.....

热点排行