【发布时间】:2016-08-04 02:16:38
【问题描述】:
我编写了一个 PL/SQL 代码来仅打印大于 id=4 的记录。我在程序中使用了goto语句,在异常中没有检测到。遇到异常后请帮我继续程序。 我的代码是
declare
cursor cur is select * from student;
c student%rowtype;
lt3 exception;
PRAGMA
exception_init(lt3,-77);
begin
open cur;
loop
<<backup>>
fetch cur into c;
if c.id < 4 then
raise lt3;
else
dbms_output.put_line(c.name);
end if;
end loop;
close cur;
exception
when lt3 then
dbms_output.put_line('Exception encountered');
goto backup;
end;
/
我应该在哪里改变?
我收到了错误
ERROR at line 24:
ORA-06550: line 24, column 7:
PLS-00201: identifier 'BACKUP' must be declared
ORA-06550: line 24, column 2:
PL/SQL: Statement ignored
【问题讨论】:
-
真的需要使用异常吗?
-
@brenners1302 我的意思是使用异常,并希望在命中后继续执行。
-
为什么不改变光标只选择 id 大于 4 的学生?
-
大声笑,我问你是否真的需要异常,你回答你的意思是使用异常?然后你接受了一个不解决使用异常的答案。
标签: sql oracle exception plsql goto