不让某个特定帐号修改某些记录,这样储发器怎样编写

[复制链接]
查看11 | 回复3 | 2013-2-25 14:51:24 | 显示全部楼层 |阅读模式
我想写个储发器,一张普通的表,不让某个特定帐号修改某些记录, 就是说如果修改了的话还会自动还原回原来的记录,请教大家应该怎么写?
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
SCOTT@ncdb>create table tab_yjg (idnumber, name varchar2(20));
Table created.
Elapsed: 00:00:01.07
SCOTT@ncdb>insert into tab_yjg select 1, 'yjg' from dual;
1 row created.
Elapsed: 00:00:00.17
SCOTT@ncdb>insert into tab_yjg select 2,'lky' from dual;
1 row created.
Elapsed: 00:00:00.00
SCOTT@ncdb>commit;
Commit complete.
Elapsed: 00:00:00.01
SCOTT@ncdb>select * from tab_yjg;

ID NAME
---------------- ---------------------

1 yjg

2 lky
2 rows selected.
Elapsed: 00:00:00.00
SCOTT@ncdb>create or replace trigger tri_tab_yjg
2before update on tab_yjg
3for each row
4declare
5begin
6if

ld.id = 2 then
7 :new.name :=

ld.name;
8end if;
9end tri_tab_yjg;
10/
Trigger created.
Elapsed: 00:00:00.39
SCOTT@ncdb>update tab_yjg set name='hm';
2 rows updated.
Elapsed: 00:00:00.01
SCOTT@ncdb>select * from tab_yjg;

ID NAME
---------------- ------------------------------

1 hm

2 lky
2 rows selected.
Elapsed: 00:00:00.01
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层



成功了,3Q QQQQQQQQ
回复

使用道具 举报

千问 | 2013-2-25 14:51:24 | 显示全部楼层
create or replace trigger if_corp_fee_info_trg_11
before INSERT ON IF_CORP_FEE_INFO
FOR EACH ROW
declare
user_name varchar2(20);
BEGIN

select Sys_context('userenv','SESSION_USER') into user_namefrom dual;
if user_name='xx' then
:new.PERS_PAY_BASE:=

ld.PERS_PAY_BASE;
end if;
END;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行