Código:
Básicamente tengo una jerarquía de bookmarks, en donde el campo 'parent' indica el bookmark padre, y 'childCount' indica cuántos hijos tiene cada bookmark.create table bookmarks( id integer unsigned not null auto_increment, name varchar(50) not null, parent integer unsigned, childCount integer unsigned not null, primary key(id) ); delimiter | create trigger updateChildCount after insert on bookmarks for each row begin if new.parent is not null then update bookmarks set childCount=childCount+1 where id = NEW.parent; end if; end; | delimiter ;
El trigger básicamente incrementa 'childCount' del padre al insertar un nuevo bookmark. El caso es que MySQL se queja porque dice que no puedo hacer un update en la misma tabla que invoca el trigger:
Cita:
¿Alguna idea de cómo hacer esto?ERROR 1442 (HY000): Can't update table 'bookmarks' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
![Adios](http://static.forosdelweb.com/fdwtheme/images/smilies/adios.gif)