--创建触发器 
Create or replace trigger biu_gqzydp_attachment 
  Before insert or update On mwt_om_fsdata 
  for each row 
  when (new.attr_id = '4DC345D9-071F-4534-B1C1-B43A93D1C988') 
declare 
  --定义变量  
  user_name varchar2(64); 
  action    varchar2(64); 
begin 
  --从另外一张表获取用户姓名 
  SELECT USER_WID INTO USER_NAME FROM MWT_OM_OBJ WHERE  OBJ_ID = :NEW.OBJ_ID; 
  --记录操作类型 
  CASE 
    WHEN inserting THEN 
      action := 'I'; 
    WHEN updating THEN 
      action := 'U'; 
  END CASE; 
  --更新日志记录 
  insert into bhdzd_log 
        (obj_id, attr_id, modify_time, modify_type,username) 
      values 
        (:new.obj_id, :new.attr_id, sysdate, action,user_name); 
end biud_gqzydp_attachment;

解决方案 »

  1.   


    Create or replace trigger biu_gqzydp_attachment 
      Before insert or update On mwt_om_fsdata 
      for each row                                  /--可改为:
      
    create or replace trigger tri_mwt_om_fsdata_biu
      before insert or update on 用户名.mwt_om_fsdata 
      for each row/--用户名为mwt_om_fsdata表所属的用户
      

  2.   


    说明没编译通过。
    你用什么工具编译的?sqlplus的话会提示你的。 pl/sql developer则可能不会提示(我遇到过)
      

  3.   

    试一下以dba权限进行授权: grant create any trigger,update any trigger,delete any trigger to test; 
      

  4.   

    以dba权限进行授权,改一下:grant create any trigger,alter any trigger,drop any trigger to Your_user;
      

  5.   

    在PLSQL的Command窗口执行SQL> alter trigger biu_gqzydp_attachment compile;看看手动编译到底报什么错误,如果不出现错误,再刷新一下左边的trigger,看看是否还有红色叉
      

  6.   

    希望大家还是帮忙看看这个trigger究竟错在哪里!
      

  7.   

    试一下:
    --创建触发器 
    Create or replace trigger biu_gqzydp_attachment
      Before insert or update On mwt_om_fsdata
      for each row
      when (new.attr_id = '4DC345D9-071F-4534-B1C1-B43A93D1C988')
    declare
      --定义变量  
      user_name varchar2(64);
      action    varchar2(64);
    begin
      --记录操作类型 
      if inserting then
        action := 'I';
      elsif updating then
        action := 'U';
      end if;
      --更新记录
      insert into bhdzd_log
        (obj_id, attr_id, modify_time, modify_type)
      values
        (:new.obj_id, :new.attr_id, sysdate, action);
    end biud_gqzydp_attachment;
      

  8.   

    最后定稿:
    --创建触发器 
    Create or replace trigger biu_gqzydp_attachment
      Before insert or update On mwt_om_fsdata
      for each row
      when (new.attr_id = '4DC345D9-071F-4534-B1C1-B43A93D1C988')
    declare
      --定义变量  
      action    varchar2(64);
    begin
      --记录操作类型 
      if inserting then
        action := 'I';
      elsif updating then
        action := 'U';
      end if;
      --更新记录
      insert into bhdzd_log
        (obj_id, attr_id, modify_time, modify_type)
      values
        (:new.obj_id, :new.attr_id, sysdate, action);
    end biud_gqzydp_attachment;
      

  9.   

    你用sqlplus执行,然后show error,这样才能针对错误给出建议。
    像这样你仅列出触发器的创建语句,而没有说相关表内容,权限,类型等等。
    让我们给你猜个答案吗?