请帮忙看看存储过程中有关游标的问题!
请帮帮忙看看呐~为什么在调用了存储过程p4以后,再查看表t1,值都是NULL呢?过程体代码:
delimiter //
create procedure p4 (IN s varchar(255),IN c varchar(255))
begin declare v_address varchar(100);
declare v_type varchar(100);
declare v_idzsfz varchar(100);
declare v_namez varchar(100);
declare v_ids varchar(100);
declare v_timesq date;
declare v_timesh date;
declare v_result varchar(100);
declare i int(1);
declare searchresult cursor //定义游标 searchresult 从 w 表中取得查询结果
for select w.adress,w.type_w,w.id_zsfz,w.name_z,w.id_s,w.time_sq,w.time_sh,w.result from w where @s = @c;
declare continue handler for not found set i =1;
set i = 0;
open searchresult;
repeat
fetch searchresult into v_address,v_type,v_idzsfz,v_namez,v_ids,v_timesq,v_timesh,v_result;
insert into t1 values(@v_address,@v_type,@v_idzsfz,@v_namez,@v_ids,@v_timesq,@v_timesh,@v_result); //将游标取得的结果集插入表 t1 中
until i
end repeat;
close searchresult;
end //
delimiter ;
调用语句:
call p4("result","StillNot");
注:调用语句中的值在w表中都有,前者是列名,后者是列中某条记录的值
帮忙看看呐~谢谢~~!
[ 本帖最后由 Muyoo 于 2010-5-24 08:57 编辑 ]