带参数的游标
create table c(part varchar2(10),name varchar2(10),id number);
insert into c values('01','a',1);
insert into c values('02','b',2);
declare
cursor mc(part varchar2) is
select c.name from c where c.part=part;
t_id c.name%type;
begin
open mc('01');
loop
fetch mc into t_id;
exit when mc%notfound;
dbms_output.put_line(t_id);
end loop;
close mc;
end;
参数是01,为什么最后02都显示出来了
------解决方案--------------------
参数不要与字段同名,这样数据库会按字段名去取
part改为v_part就不会了