1.定义游标时
cursor cursorname is select * from table for update ;
2.使用游标时
for aaa in cursorname loop
update a set name='sss' where ... current of cursorname
end loop;
同意楼上的,用fetch打开游标,然后用for循环得到游标值
create or replace procedure p_test_refcur is
v_refcur PKG_RefCursor.Refcursor;
--cursor cur is select * from sys.seq$;
cursor c1 is select * from t_mode for update ;
v_count integer;
begin
--prc_Test_refcursor(v_refcur);
open v_refcur for 'select count(*) from t_pay_mode';
fetch v_refcur into v_count;
dbms_output.put_line(v_count);
--aa;
--open c1;
for v1 in c1 loop
if v1.mode_id=1 then
update t_mode set mode_Name='现在1' where mode_id=v1.mode_id;
--1.mode_name:='现在2';
null;
end if;
end loop;
end p_test_refcur;
create or replace procedure p_test_refcur is
v_refcur PKG_RefCursor.Refcursor;
--cursor cur is select * from sys.seq$;
cursor c1 is select * from t_mode for update ;
v_count integer;
begin
--prc_Test_refcursor(v_refcur);
open v_refcur for 'select count(*) from t_pay_mode';
fetch v_refcur into v_count;
dbms_output.put_line(v_count);
--aa;
--open c1;
for v1 in c1 loop
if v1.mode_id=1 then
update t_mode set mode_Name='现在1' where mode_id=v1.mode_id;
--1.mode_name:='现在2';
null;
end if;
end loop;
end p_test_refcur;