Question

a été suggéré qui est logiquement DDL réalisé quelque chose comme ceci:

begin
    COMMIT;
    perform any appropriate pre-DDL trigger code;
    do the ddl;
    perform any appropriate post-DDL trigger code;
    COMMIT;
exception
    when others then
         ROLLBACK;
         raise;
end;

Ce qui suggère que toute erreur dans un déclencheur causerait la LDD à laminer en arrière. Est-ce le cas?

Était-ce utile?

La solution

La réponse, au moins sur 11.2, est « ça dépend »:

Cette create est annulée:

create trigger trig_foo after create on schema
begin
  raise_application_error(-20001, 'Dont do it!');
end;
/
--
create table foo as select level as id from dual connect by level<=10000;
/*
SQL Error: ORA-00604: error occurred at recursive SQL level 1
ORA-20001: Dont do it!
*/
--
select count(*) from foo;
/*
SQL Error: ORA-00942: table or view does not exist
*/

Mais ce n'est pas truncate:

create table foo as select level as id from dual connect by level<=10000;
--
create trigger trig_foo after truncate on schema
begin
  raise_application_error(-20001, 'Dont do it!');
end;
/
--
truncate table foo;
/*
SQL Error: ORA-00604: error occurred at recursive SQL level 1
ORA-20001: Dont do it!
*/
select count(*) from foo;
/*
COUNT(*)               
---------------------- 
0                  
*/
Licencié sous: CC-BY-SA avec attribution
Non affilié à dba.stackexchange
scroll top