drop table b;
drop table a;

create table a (
  a1 integer primary key,
  a2 integer
);

create table b (
  b1 integer primary key,
  b2 integer references a
);

insert into a values (1, 3);
insert into a values (2, 6);
insert into b values (13, 1);
insert into b values (14, 1);
insert into b values (15, 1);

create trigger OnDelSetNull
  before delete on a
  for each row
  begin
    update b 
      set b2 = null
      where b2 = :old.a1;
  end;
/

delete from a where a1 = 1;
