Bo's Oracle Station

查看: 1161|回复: 0

课程第18次

[复制链接]

27

主题

27

帖子

183

积分

超级版主

Rank: 8Rank: 8

积分
183
发表于 2019-11-2 09:13:25 | 显示全部楼层 |阅读模式

  1. create table tvalue  ( a  varchar2(2000)) tablespace tbsaudit;




  2. create or replace trigger trg_value
  3. after update of salary on hr.employees
  4. referencing new as new old as old
  5. for each row
  6. begin
  7.   if :old.salary != :new.salary
  8.   then
  9.      insert into tvalue
  10.       values( to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS')||' '||sys_context('userenv','ip_address')||' '||
  11.              sys_context('userenv','os_user')||' '||
  12.                sys_context('userenv','session_user')||' '||
  13.                sys_context('userenv','current_user')||' modified from '||:old.salary||' to '||:new.salary||' the employee_id is '||              
  14.           :old.employee_id );   
  15.                  
  16.   end if;
  17. end;


  18. select  * from user_errors;

  19. select  * from dba_source s where s.name='TRG_VALUE';

  20. select  * from tvalue order by 1  desc;
复制代码
   A
12019-10-20:22:38:25  oracle SYS SYS modified from 99999 to 100000 the employee_id is 100
22019-10-20:22:38:01  oracle HR SYS modified from 60005 to 99999 the employee_id is 100
32019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 206
42019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 205
52019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 204
62019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 203
72019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 202
82019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 201
92019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 200
102019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 199
112019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 198
122019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 197
132019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 196
142019-10-20:22:38:01  oracle HR SYS modified from 60000 to 99999 the employee_id is 195



回复

使用道具 举报

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

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-20 03:31 , Processed in 0.031637 second(s), 24 queries .

快速回复 返回顶部 返回列表