create or replace trigger pay_result_update
before update on pay_result
for each row
declare
num number;
begin
select conut(1) into num from pay_his where where batch=:new.batch and payyear=:new.payyear
and paymonth=:new.paymonth and p_id=:new.p_id
and payitem=:new.payitem;
if num then
update pay_his set cost_ceneter='nothing'
where batch=:new.batch and payyear=:new.payyear
and paymonth=:new.paymonth and p_id=:new.p_id
and payitem=:new.payitem;
else
insert into pay_his values(:new.col_name,.....);
end if;
end;
/
before update on pay_result
for each row
declare
num number;
begin
select conut(1) into num from pay_his where where batch=:new.batch and payyear=:new.payyear
and paymonth=:new.paymonth and p_id=:new.p_id
and payitem=:new.payitem;
if num then
update pay_his set cost_ceneter='nothing'
where batch=:new.batch and payyear=:new.payyear
and paymonth=:new.paymonth and p_id=:new.p_id
and payitem=:new.payitem;
else
insert into pay_his values(:new.col_name,.....);
end if;
end;
/
解决方案 »
- DROP表后 在回收站里 怎么查到 并且还原
- oracle paralel 并行查询的困惑,高手请进!
- job如何做到定时运行,并且在系统重启后,也能做到定时运行
- 怎样能提高带有索引表的删除记录的效率
- 各位请帮下书忙:我的oracle中的OracleOraDb10g_home1TNSListener服务启动不了
- 请问关于oracle数据库表的容量是多少?
- 我要关联的两张表位于两个不同的数据库服务器上....我怎样将他们关联起来...
- oracle 数据迁移的 sqlServer的问题
- 如何对视图(view)进行更新
- 关于flashback_transaction_query和dba_fga_audit_trail(已经commit)数据不能匹配的问题
- oracle中有没有类似sqlserver中的用于备份与恢复的存储过程,可用于jsp开发?不胜感激。
- 查询一个用户建立的所有表,sql语句是什么?
t_temp number;
select count(1) into number from pay_his where batch=:old.batch and payyear=:old.payyear
and paymonth=:old.paymonth and p_id=:old.p_id
and payitem=:old.payitem;
if number>0 then
update ....
else
insert into ....
end if;
end;
不过你们没有明白我的意思。
我是说从 update 的语句中应该有个返回值表明你 update 了那一行。
所以我可以直接通过知道 update 失败来知道table中没有这个数据。
而不用通过 select 预先查寻。
不是说这个提议好,但是我想知道该如何做,如何去得到那个update后的row.
谢谢你们。
请再发言。
if SQL%ROWCOUNT = 0 then
insert into ....
end if;
begin
update ....;
if sql%notfound then
insert into ....;
end if;
end;
/
给分。结贴。