本帖最后由 mafeifan 于 2012-02-02 16:34:22 编辑

解决方案 »

  1.   


    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;
      

  2.   

    看不太懂啊 
    for rec in (select id,A,B from test)
    是什么意思
      

  3.   


    定义游标把select结果放到结构体变量rec中,取的时候通过rec.id取出