有个Table T1(id,col1,col2,col3),表中有若干条记录,需要有条件地更新col2、col3的内容。比如在col1满足一定条件的记录中,将col2、col3依次设置为:col2 col3
1 1
1 2
1 3
...
1 100
2 1
2 2
2 3
...
3 1
3 2
3 3
...
...
...
1 1
1 2
1 3
...
1 100
2 1
2 2
2 3
...
3 1
3 2
3 3
...
...
...
col2 col3
1 1
1 2
1 3
...
1 100
2 1
2 2
2 3
...
2 100
3 1
3 2
3 3
...
...
...
j pls_integer;
type coll_type is table of hcmtest.id%type;
ids coll_type;
begin
i:=1;
j:=1;
execute immediate 'select id from hcmtest where id>:id'
bulk collect into ids
using 3;
dbms_output.put_line(ids.count);
for p in 1..ids.count loop
update hcmtest set col2=i,col3=j where id = ids(p);
if(j=100) then
j:=1;
i:=i+1;
else
j:=j+1;
end if;
end loop;
commit;end test;