-- 自定义例外
create or replace procedure extest(pnum number)
is
--定义一个自定义例外;
myex exception;
begin
update emp set sal =sal-100 where empno=pnum;
--定义例外触发条件:sql%notfound 表示没有update;
if sql%notfound then
--raise myexception表示触发我自定义的例外;
raise myex;
end if;
--例外处理操作;
exception
when myex then
dbms_output.put_line('提示:没有更新数据!');
end;
-- 创建视图;
create or replace view myview as
select * from emp where sal<3000
--with check option 表示用户对视图的操作的限制;
--当用户企图添加 工资大于3000 的记录的时候,则不能成功;
--注意的是:此限制只是对视图有效,不影响基表。
with check option;
--注意!注意! :对于视图的操作,会相应的将改变保存到基表中。
--创建只读视图
create or replace view myview as
select * from emp where sal<3000
with read only;
--使用dba_views 和 user_views 数据字典查看视图信息;
select * from user_views;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24465008/viewspace-692331/
,如需转载,请注明出处,否则将追究法律责任。