Jan 022013
create trigger nuclear_fission 
for update on  uranium compound trigger

  cursor remaining_material is
    select rowid, u.*
    from   uranium u
    where  atomic_mass = 235
    and    rownum <= 
      (select count(*) from neutrons);
  fissile_matter remaining_material%rowtype;
  after each row is 
    if :new.atomic_mass = 236 then 
      insert into krypton (atomic_mass) 
      values (92);
      insert into barium  (atomic_mass) 
      values (141);
      insert into neutrons (atomic_mass) 
      values (1);
      insert into neutrons (atomic_mass) 
      values (1);
      insert into neutrons (atomic_mass) 
      values (1);
    end if;
  end after each row;

  after statement is
    open remaining_material;
      fetch remaining_material 
      into  fissile_matter; 
      exit when remaining_material%notfound;
      update uranium
      set    atomic_mass = atomic_mass + 
        (select atomic_mass 
         from   neutrons 
         where  rownum = 1)
      where  atomic_mass = 235
      and    rowid = fissile_matter.rowid;
      delete neutrons;
    end loop;
    close remaining_material;
    delete uranium 
    where  atomic_mass = 236;
  end after statement;
/It may not generate your database any extra power, 
but at least you won't have to deal with leftover radioactive material

To start your own nuclear reaction, use this.

Nov 072012

Click the image for SQL you can run to see the “DML restart” problem in action.

For an explanation, see the following Tom Kyte series: