触发更新值

时间:2012-05-16 06:42:22

标签: sql oracle triggers plsql

我想在我的表Audit上创建一个触发器 触发器的功能是: 它会将所有值设置为NULL 字符串'null' 意味着'null' -> NULL 我应该怎么做呢?我希望每个专栏都没有。

1 个答案:

答案 0 :(得分:3)

PL / SQL中没有任何反映,所以你需要这样做:

create or replace trigger aud_upd_biur
before insert or update on your_audit_table
for each row
begin
     if :new.col1 = 'null'
     then
         :new.col1 := null;
     end if;
     if :new.col2 = 'null'
     then
         :new.col2 := null;
     end if;
     ....
     if :new.col99 = 'null'
     then
         :new.col99 := null;
     end if;
end;

所以,如果你的审计表只有几列cut'n'paste就足够了。否则,您可以从数据字典中生成代码。

相关问题