ITPub博客

首页 > 数据库 > Oracle > trigger on clob

trigger on clob

原创 Oracle 作者:warmbreeze 时间:2015-12-03 13:37:45 0 删除 编辑


SCOTT  @ db1 >select * from v$version;


BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE    10.2.0.5.0      Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production

(不能在sys的表上建trigger)
SCOTT  @ db1 >show user
USER is "SCOTT"


SCOTT  @ db1 >create table T ( a clob, b clob );


Table created.


SCOTT  @ db1 >create or replace trigger t_trigger 
  2  before insert or update on T
  3  for each row
  4  begin
  5    if :new.a != :new.b then
  6       raise_application_error(-20000,'failed');
  7    end if;
  8  end;
  9  /


Trigger created.


SCOTT  @ db1 >insert into T values ('aaa','aaa');


1 row created.


SCOTT  @ db1 >update T set a = 'bbb';
update T set a = 'bbb'
       *
ERROR at line 1:
ORA-20000: failed
ORA-06512: at "SCOTT.T_TRIGGER", line 3
ORA-04088: error during execution of trigger 'SCOTT.T_TRIGGER'

trigger已生效
下面用dbms_lob.writeappend修改log:
SCOTT  @ db1 >declare
  2    c clob;
  3  begin
  4    select b into c from t for update;
  5    dbms_lob.writeappend(c,5,'aaaaa');
  6  commit;
  7  end;
  8  /


PL/SQL procedure successfully completed.


SCOTT  @ db1 >select * from t;


A
--------------------------------------------------------------------------------
B
--------------------------------------------------------------------------------
aaa
aaaaaaaa

trigger没有触发


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/37279/viewspace-1852414/,如需转载,请注明出处,否则将追究法律责任。

下一篇: event 10261 and pga
请登录后发表评论 登录
全部评论

注册时间:2012-02-15

  • 博文量
    45
  • 访问量
    42544