table_id table_name table_num table_content table_status
1 一 123455 一内容 0
1 二 123456 二内容 1
1 三 123451 三内容 0
table_a table_b table_num table_c
1 一 123457 一内容
1 二 123456 二内容
1 三 123458 三内容
1 一 123455 一内容 0
1 二 123456 二内容 1
1 三 123451 三内容 0
table_a table_b table_num table_c
1 一 123457 一内容
1 二 123456 二内容
1 三 123458 三内容
update table1 set table_status=(select case when (select 1 from table1 aa,table2 bb where bb.table_num=aa.table_num) is not null then 1
else
0
end )
where table_num exists(select b.table_num from table1 a,table2 b where b.table_num=a.table_num)
create or replace
TRIGGER ad
after insert or update
ON 表1
FOR EACH ROW
declare
v_count number(10);
begin
select count(*) into :v_count from 表2 where table_num=:new.table_num;
if v_count>0 then
update 表1 set table_status=1;
else
update 表1 set table_status=0;
end if;
end;