在命令的第1行开始出错:
DECLARE
x NUMBER := 0;
counter NUMBER := 0;
BEGIN
FOR i IN 1..4 LOOP
x := x + 1000;
counter := counter + 1;
INSERT INTO temp VALUES (x, counter, 'in OUTER loop');
END;
END LOOP;
COMMIT;
END;
错误报告:
ORA-06550: line 11, column 10: PLS-00103: Encountered the symbol ";" when expecting one of the following: loop 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
答案 0 :(得分:4)
此插入模式不需要PL / SQL。以下适用于纯SQL:
create table temp(x number, counter number, text varchar2(20));
insert into temp
select (rownum-1)*1000, rownum-1, 'in OUTER loop'
from dual
connect by level <=4;
答案 1 :(得分:2)
第11行的第一个END;
不应该在那里:
DECLARE
x NUMBER := 0;
counter NUMBER := 0;
BEGIN
FOR i IN 1..4 LOOP
x := x + 1000;
counter := counter + 1;
INSERT INTO temp VALUES (x, counter, 'in OUTER loop');
END LOOP;
COMMIT;
END;
如果您在INSERT
(例如)周围有一个子块,您只需要它,例如用于特定的异常处理。
通常,在INSERT
:
INSERT INTO temp(col1, col2, col3) VALUES (x, counter, 'in OUTER loop');