declare
type array is table of src%rowtype index by binary_integer;
l_data array ;
begin
loop
begin
select * bulk collect into l_data
from src
where processed = 'N'
and rownum < 10
for update of processed;
exit when sql%rowcount = 0;
exception
when no_data_found then exit;
end;
for i in 1 .. l_data.count
loop
update tgt set x = l_data(i).x , y = l_data(i).y where rowid = l_data(i).tgt_row_id ;
update src set processed = 'Y' where tgt_row_id = l_data(i).tgt_row_id;
end loop;
commit;
end loop;
end;
/
我編輯了代碼以使用批量收集,但它只是掛在11.2中。提交在循環中
SQL> select * from src;
X Y TGT_ROW_ID P
---------- ---------- ------------------ -
1 ABC AAAWZDAAEAAAA1EAAA Y
1 DEF AAAWZDAAEAAAA1EAAA Y
2 ABC AAAWZDAAEAAAA1EAAC Y
SQL> select * from tgt;
X Y
---------- ----------
1 ABC
1
2 ABC
您的問題是什麼? – YXD 2011-06-08 14:34:39
抱歉,我不確定我無法格式化這個 – lisa 2011-06-08 14:38:38
@Lisa我編輯了您的問題。只是你知道,要格式化代碼,所有你需要做的就是選擇文本按下'{}'按鈕 – 2011-06-08 14:40:48