PLSQL总结——7.异常1

来源:互联网 发布:有关动漫的软件 编辑:程序博客网 时间:2024/06/13 09:08
---------------------------------------sqlcode和sqlerrmdeclare  a number;begin  a := 'r';  dbms_output.put_line(a);exception  when others then    dbms_output.put_line(sqlcode || ',' || sqlerrm);end;---------------------------------------抛出自定义异常1declare  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;--------------------------------------抛出自定义异常2declare  exception_test constant number := -20001;begin  raise_application_error(exception_test, 'sss'); --抛出程序显示错误exception  when others then    dbms_output.put_line(sqlcode || ',' || sqlerrm);end;--------------------------------------抛出自定义异常3declare  exception_test exception;  pragma exception_init(exception_test, -20001);begin  raise exception_test;exception  when others then    dbms_output.put_line(sqlcode || ',' || sqlerrm);end;