WEB开发网
开发学院数据库Oracle Oracle概念:异常和游标 阅读

Oracle概念:异常和游标

 2009-06-09 13:15:38 来源:WEB开发网   
核心提示: dbms_output.put_line(‘block 4’);end;exceptionwhen NO_DATA_FOUND thendbms_output.put_line(‘block 3’);end;exceptionwhen NO_

dbms_output.put_line(‘block 4’);

end;

exception

when NO_DATA_FOUND then

dbms_output.put_line(‘block 3’);

end;

exception

when NO_DATA_FOUND then

dbms_output.put_line(‘block 2’);

end;

exception

when NO_DATA_FOUND then

dbms_output.put_line(‘block 1’);

end;

/

作用域和可视性:

begin

declare

nested_excp exception;

begin

raise nested_excp;

end;

exception

when nested_excp then

dbms_output.put_line('haha');

end;

/

when others then

放在最后

begin

declare

nested_excp exception;

begin

raise nested_excp;

end;

exception

when others then

dbms_output.put_line('haha');

dbms_output.put_line(sqlcode || ‘ is ’ || sqlerrm);

raise;

end;

/

SQLCODE SQLERRM

declare

l_dept departments%rowtype;

begin

l_dept.department_id:=100;

l_dept.department_name:=’HR’;

insert into departments(department_id, department_name)

values(l_dept.department_id, l_dept.department_name);

Exception

When others then

dbms_output.put_line(sqlcode || ‘ is ’ || sqlerrm);

end;

/

declare

l_dept departments%rowtype;

begin

l_dept.department_id:=100;

l_dept.department_name:=’HR’;

insert into departments(department_id, department_name)

values(l_dept.department_id, l_dept.department_name);

Exception

When others then

Raise_application_error(-20001, ‘error message!’);

End;

/

系列文章:

Oracle概念:过程、函数、程序包

Oracle概念:同义词、序列与视图

上一页  1 2 3 4 5 6 

Tags:Oracle 概念 异常

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接