然到非要这样才能使用带参数的游标??(下面的我编译且执行过了。) create or replace procedure aaa as cursor cur_a(mlv number) is select * from a where lv=mlv; aa a%rowtype; begin for i in 1..3 loop open cur_a(i); fetch cur_a into aa; while cur_a%found loop update a set jz=gz*i*0.1 where bh=aa.bh; fetch cur_a into aa; end loop; close cur_a; end loop; end;
pl/sql里面的游标有自己的用法,先看看比较好啦.
BEGIN OPEN cur_exists('2198', 'BU'); loop FETCH cur_exists into isExists; exit when cur_exists%notfound; if(isExists<>0) dbms_output.put_line('存在'); end if; end loop; close cur_exists; END P_SET_NUMBER;
应该是if后面写错了,没有()这里的语法不同,回去好好看看书吧。CREATE OR REPLACE PROCEDURE newtest AS isExists number(2); CURSOR cur_exists(org number, otype varchar2) IS select count(1) from number_d where orgid=org and ordtype=otype and rownum<2; BEGIN OPEN cur_exists(2198, 'BU'); FETCH cur_exists into isExists; if isExists=1 then dbms_output.put_line(1); end if; CLOSE cur_exists; END newtest;
少了个then if (isExists<>0) then dbms_output.put_line('存在'); end if;
create or replace procedure aaa as
cursor cur_a(mlv number) is select * from a where lv=mlv;
aa a%rowtype;
begin
for i in 1..3 loop
open cur_a(i);
fetch cur_a into aa;
while cur_a%found loop
update a set jz=gz*i*0.1 where bh=aa.bh;
fetch cur_a into aa;
end loop;
close cur_a;
end loop;
end;
OPEN cur_exists('2198', 'BU');
loop
FETCH cur_exists into isExists;
exit when cur_exists%notfound;
if(isExists<>0)
dbms_output.put_line('存在');
end if;
end loop;
close cur_exists;
END P_SET_NUMBER;
isExists number(2);
CURSOR cur_exists(org number, otype varchar2)
IS select count(1) from number_d
where orgid=org and ordtype=otype and rownum<2;
BEGIN
OPEN cur_exists(2198, 'BU');
FETCH cur_exists into isExists;
if isExists=1 then
dbms_output.put_line(1);
end if;
CLOSE cur_exists;
END newtest;
dbms_output.put_line('存在');
end if;