在oracle中创建一个exception

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:

薪水超出范围

 

主要注意语法的问题

你可能感兴趣的:(oracle)