ITeye博客

在oracle中创建一个exception

danielhjd · 2011-05-24 19:24 · Oracle · 数据库 · Oracle · Markdown

Gramma:

 

1:声明一个exceptin:

 declare

 exception_name exception;

 

2:触发一个exception;

 raise exception_name;

 

3:捕获一个exception

when exception_name1 then statements;

when exception_name2 then statements

 

代码:

declare
a exception;
t_salary employee.salary%type;
begin
select salary into t_salary from employee where employee.empid=13;
if t_salary>2000 then
raise a;
end if;
exception
when a then
dbms_output.put_line('薪水超出范围');
end;

 

output:

薪水超出范围

 

主要注意语法的问题

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。