6 个解决方案
#1
create table a(
id int,
col varchar2(3)
);
insert into a values(1,'');
insert into a values(2,'');
create or replace trigger a_del
after delete on a
begin
update a set col='男';
end;
/
delete a where id=1;
select * from a;
#2
自治事务。。。。
pragma autonomous_transaction
pragma autonomous_transaction
#3
哎,这么奇怪的需求啊,
只好用自治事务,不过不是万不得已,不要这么做。
只好用自治事务,不过不是万不得已,不要这么做。
create or replace trigger a_trigger
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
#4
update a set sex='男' where rowid != :old.rowid;
--或者
update a set sex='男';
#5
create or replace trigger a_trigger
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
#6
create or replace trigger a_trigger
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
#1
create table a(
id int,
col varchar2(3)
);
insert into a values(1,'');
insert into a values(2,'');
create or replace trigger a_del
after delete on a
begin
update a set col='男';
end;
/
delete a where id=1;
select * from a;
#2
自治事务。。。。
pragma autonomous_transaction
pragma autonomous_transaction
#3
哎,这么奇怪的需求啊,
只好用自治事务,不过不是万不得已,不要这么做。
只好用自治事务,不过不是万不得已,不要这么做。
create or replace trigger a_trigger
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
#4
update a set sex='男' where rowid != :old.rowid;
--或者
update a set sex='男';
#5
create or replace trigger a_trigger
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
#6
create or replace trigger a_trigger
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;
after delete on a
for each row
declare
pragma autonomous_transaction;
begin
update a set sex='男' where rowid != :new.rowid;
commit;
end;