create or replace trigger updateA
after update on A
for each row
begin
if :old.AA != :new.AA then
begin
update B set AA=:new.AA where id=:old.id;
end;
end if; if :old.BB != :new.BB then
begin
update B set BB=:new.BB where id=:old.id;
end;
end if;
end;
两个表 A.(id,AA,BB) B(id,AA,BB)
更新A表 触发器更新B表.请教:
为什么我更新1个字段的时候可以完成. 只更新AA 或者 只 更新BB 都可以完成.
但是 如果我 一次更新2 个字段 update A set AA='11',BB='22' where id=1, 却只更新了 B 表的 AA 字段.为什么啊?该怎么写这个触发器呢. 谢谢
after update on A
for each row
begin
if :old.AA != :new.AA then
begin
update B set AA=:new.AA where id=:old.id;
end;
end if; if :old.BB != :new.BB then
begin
update B set BB=:new.BB where id=:old.id;
end;
end if;
end;
两个表 A.(id,AA,BB) B(id,AA,BB)
更新A表 触发器更新B表.请教:
为什么我更新1个字段的时候可以完成. 只更新AA 或者 只 更新BB 都可以完成.
但是 如果我 一次更新2 个字段 update A set AA='11',BB='22' where id=1, 却只更新了 B 表的 AA 字段.为什么啊?该怎么写这个触发器呢. 谢谢
解决方案 »
- oracle数据库中,如何能够查询到一条记录产生的时间?
- 如何格式化时间差
- 如何将某个目录下的所有图片批量导入oracle数据库中
- linux 下oracle 10g安装成功后如何启动sqlpuls??
- Oracle9 能从远程导出数据吗?用exp命令还是用“数据管理--导出”??
- 取出的记录有重复!对重复记录进行唯一约束的函数???
- oracle里面如何知道一个游标的sql语法里面有多少个字段slect a,b,c from tablename 知道是3各字段
- 在win2000下如何访问安装在redhat7.3上的ORACLE8.1.7 数据库?
- 怎么书写select 语句的from 中变量组合?
- 在存储过程中使用 merge into语句调用过程时报错,求解决办法
- 谁来帮我看看用C++封装的SQL语句啊?
- Oracle序列问题
create or replace trigger updateA
after update on A
for each row
begin
if :old.AA != :new.AA or :old.BB != :new.BB then
begin
update B set AA=:new.AA,BB=:new.BB where id=:old.id;
end;
end if;
end; 只用一个update语句就好了
after update of aa,bb on A
for each row
begin
if :old.AA != :new.AA then
begin
update B set AA=:new.AA where id=:old.id;
end;
end if; if :old.BB != :new.BB then
begin
update B set BB=:new.BB where id=:old.id;
end;
end if;
end;
AA 和 BB 是 字符型的.
应该怎么转下类型呢? 转成 num 的.?谢谢了.