-------------------------------------
--sqlcode和sqlerrm
declare
a number;
begin
a := 'r';
dbms_output.put_line(a);
exception
when others then
dbms_output.put_line(sqlcode || ',' || sqlerrm);
end;
-------------------------------------
--抛出自定义异常1
declare
e exception;
begin
raise e;
exception
when e then
dbms_output.put_line('e exception!');
when others then
dbms_output.put_line(sqlcode || ',' || sqlerrm);
end;
------------------------------------
--抛出自定义异常2
declare
exception_test constant number := -20001;
begin
raise_application_error(exception_test, 'sss'); --抛出程序显示错误
exception
when others then
dbms_output.put_line(sqlcode || ',' || sqlerrm);
end;
------------------------------------
--抛出自定义异常3
declare
exception_test exception;
pragma exception_init(exception_test, -20001);
begin
raise exception_test;
exception
when others then
dbms_output.put_line(sqlcode || ',' || sqlerrm);
end;
PLSQL总结——7.异常1
最新推荐文章于 2022-10-15 17:56:01 发布