以下代码可以编译和运行:
begin
for l in (select 1 as v
from dual
union
select 2 as v
from dual
union
select 3 as v
from dual) loop
if l.v = 3 then
l.v := 3.14; -- > modify the cursor value ?!
end if;
dbms_output.put_line('=> ' || l.v);
end loop;
end;
=> 1
=> 2
=> 3.14
循环执行此操作是否是一种好习惯,例如修改游标的值?
这样做有什么影响?如果我在游标中声明了select
,那么当我再次读取游标时,它会修改值吗?
谢谢