create table table_info( xm varchar2(20), sex varchar2(20), age varchar2(20)); create table table_info_temp( xm varchar2(20), sex varchar2(20), age varchar2(20));declare cur_update sys_refcursor; temp_date table_info_temp%rowtype; begin open cur_update for select * from table_info where sex='1'; loop exit when cur_update%notfound; fetch cur_update into temp_date; insert into table_info_temp values temp_date; end loop; close cur_update; end;
create or replace trigger trgname after insert or update or delete on table_info for each row declare cur_update sys_refcursor; temp_date table_info_temp%rowtype; begin open cur_update for select * from table_info where sex='1'; loop exit when cur_update%notfound; fetch cur_update into temp_date; insert into table_info_temp values temp_date; end loop; close cur_update; end;
hnzpabc(窗外的猪是多么不一样錯!錯!錯! 你連new, old都沒引用到
CREATE OR REPLACE TRIGGER tr_sec_UpdateAnoy after UPDATE ON table_info FOR EACH ROW BEGIN
if :old.age <> :new.age then insert into table_info_temp values(:old.xm, :old.sex, :old.age); END IF; END;
xm varchar2(20),
sex varchar2(20),
age varchar2(20));
create table table_info_temp(
xm varchar2(20),
sex varchar2(20),
age varchar2(20));declare
cur_update sys_refcursor;
temp_date table_info_temp%rowtype;
begin
open cur_update for select * from table_info where sex='1';
loop
exit when cur_update%notfound;
fetch cur_update into temp_date;
insert into table_info_temp values temp_date;
end loop;
close cur_update;
end;
after insert or update or delete on table_info
for each row
declare
cur_update sys_refcursor;
temp_date table_info_temp%rowtype;
begin
open cur_update for select * from table_info where sex='1';
loop
exit when cur_update%notfound;
fetch cur_update into temp_date;
insert into table_info_temp values temp_date;
end loop;
close cur_update;
end;
你連new, old都沒引用到
after UPDATE ON table_info
FOR EACH ROW
BEGIN
if :old.age <> :new.age then
insert into table_info_temp values(:old.xm, :old.sex, :old.age);
END IF;
END;