56,687
社区成员
发帖
与我相关
我的任务
分享
declare tempid int;
select tempid=id from table where tempname='需求';
select @tempid:=id from table where tempname='需求';
declare tempid int;
declare mycursor CURSOR for select id from table where id=tempid;
如上我的tempid这个变量是需要后面取得并且赋值的 但是如果:
declare tempid int;
set tempid=2;
declare mycursor CURSOR for select id from table where id=tempid;
这样定义的话 会编译不过,那么我只能把游标的定义提前,
那么当我后面打开游标 我当然希望我的变量能影响游标的结果,比如:
declare tempid int;
declare mycursor CURSOR for select id from table where id=tempid;
set tempid=2;
open mycursor;
希望游标执行的话 里面的变量tempid=2,如果这样不行的话,那么应该怎么处理呢?select tempid:=id from table where tempname='需求';
这样 编译是通不过的.