本帖最后由 bell6248 于 2014-11-10 14:35 编辑
在137和138之间加一行, 并加上"NULL;", 这段代码即可解决,
即:
........
end;
<>
null;
end loop;
..........
举个类似的例子如下:
SQL>
SQL> declare
2 v_name emp.ename%type;
3 begin
4 for i in (select deptno from dept) loop
5
6 begin
7 select ename into v_name from emp where deptno = i.deptno and rownum <= 1;
8
9 exception
10 when no_data_found then
11 dbms_output.put_line(i.deptno || ' doesn''t exist');
12 goto next_loop;
13 end;
14
15 <>
16
17 end loop;
18 end;
19 /
declare
v_name emp.ename%type;
begin
for i in (select deptno from dept) loop
begin
select ename into v_name from emp where deptno = i.deptno and rownum <= 1;
exception
when no_data_found then
dbms_output.put_line(i.deptno || ' doesn''t exist');
goto next_loop;
end;
<>
end loop;
end;
ORA-06550: line 17, column 4:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
begin case declare exit for goto if loop mod null raise
return select update while with
<<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
SQL>
SQL>
SQL> declare
2 v_name emp.ename%type;
3 begin
4 for i in (select deptno from dept) loop
5
6 begin
7 select ename into v_name from emp where deptno = i.deptno and rownum <= 1;
8
9 exception
10 when no_data_found then
11 dbms_output.put_line(i.deptno || ' doesn''t exist');
12 goto next_loop;
13 end;
14
15 <>
16 null;
17
18 end loop;
19 end;
20 /
40 doesn't exist
PL/SQL procedure successfully completed
SQL>