Declare i Number:=0; Begin Loop i:=i+1; For c_num In (Select Id From user1) Loop If c_num.id=i Then Insert Into User2(Id) Values (c_num.id); Else Insert Into user2(num) Values (i); End If; End Loop ; Exit When i=5; End Loop; Commit; End;
但是结果是插入了5次 Select * From user2 id num 1 1 1 1 1 2 2 2 2 2 3 3 .....