create or replace procedure my_proc(i int) is
begin
while i<20 loop
insert into test values(i,'avb');
i := i+1;
end loop;
end;
------解决方案--------------------
- SQL code
Errors for PROCEDURE MY_PROC:LINE/COL ERROR-------- -----------------------------5/3 PL/SQL: Statement ignored5/3 PLS-00363: expression 'I' cannot be used as an assignment target-- 传入的参数 i 在 while 循环中不应该被引用,这个时候应该用for 循环-- 修改为:create or replace procedure my_proc(i int) isbegin for t in 1..i loop insert into test values(t,'avb'); end loop; commit; -- 别忘记提交end;/lym@TDWORA> exec my_proc(30);PL/SQL procedure successfully completed.lym@TDWORA> select * from test; ID CNAME---------- -------------------- 1 avb 2 avb 3 avb 4 avb 5 avb 6 avb 7 avb 8 avb 9 avb 10 avb 11 avb 12 avb 13 avb 14 avb 15 avb 16 avb 17 avb 18 avb 19 avb 20 avb 21 avb 22 avb 23 avb 24 avb 25 avb 26 avb 27 avb 28 avb 29 avb 30 avb30 rows selected.