oracle中,表A中共有a,b,c三个字段,c初始为0,只要a或b发生改变,那么c值变为1
表A
a b c
1 1 0
1 2 0
1 3 0
如果
表A数据改变,希望对变化数据添加标识,即c变为1
a b c
1 1 0
2 2 1
3 3 1
各位大神,在oracle 中该怎么实现呢???
表A
a b c
1 1 0
1 2 0
1 3 0
如果
表A数据改变,希望对变化数据添加标识,即c变为1
a b c
1 1 0
2 2 1
3 3 1
各位大神,在oracle 中该怎么实现呢???
解决方案 »
- 求查询语句
- 读取clob类型的字段内容时出错
- Oracle 查询远端服务器的中文字段为空
- LINUX下Oracle数据库磁盘规划要注意什么,我们用EVA4400
- [高分200求助]一个简单的查询的存储过程为什么老是不能执行!
- 编译java source 出错!
- 急问:access数据库中的数据可以直接导到oracle吗?
- pro c 文件make时候,oraca.h 引用失败
- 怎样解决ORALCE中分页时,用count(*)来取得总记录数所耗时间过长得问题。
- 请问Oracle里有起全局变量作用的东东吗?
- Oracle 疑难杂症,高手请帮忙。
- Oracle存储过程由多个out参数,某些地方调用的时候只需要部分out返回,怎么可以少写几个参数
create or replace trigger is tri_name
after update on tableName
for each row--这个一般都要加上,因为我们一般都是行级触发器,即对每一行都操作
declare --若没有变量,则可以省略declarebegin
if :new.a<>:old.a or :new.b<>:old.b then
update tableName t set t.c=1 where t.a=:old.a and t.b=:old.b;
end if;
end;
after update on tableName
for each row--这个一般都要加上,因为我们一般都是行级触发器,即对每一行都操作
declare --在变量申明的地方,指定自定义事务处理。
pragma autonomous_transaction;
begin
if :new.a<>:old.a or :new.b<>:old.b then
update tableName t set t.c=1 where t.a=:old.a and t.b=:old.b;
commit;
end if;
end;
before update on 表名
for each row
when (old.a!=new.a or old.b!=new.b)
begin
:new.c:=1;
end;
/