declare -- Local variables here random_num number; begin -- Test statements here for rec in (select id,A,B from test) loop select trunc(dbms_random.value(1,10)) into random_num from dual;
if random_num <= rec.A then update test t set t.B = 1 where t.id = rec.id; end if;
declare
-- Local variables here
random_num number;
begin
-- Test statements here
for rec in (select id,A,B from test)
loop
select trunc(dbms_random.value(1,10))
into random_num
from dual;
if random_num <= rec.A
then
update test t set t.B = 1 where t.id = rec.id;
end if;
end loop;
end;
for rec in (select id,A,B from test)
是什么意思
定义游标把select结果放到结构体变量rec中,取的时候通过rec.id取出