Re: update trigger
Posted in 2009
tomcaml@gmail.com pisze: > hello all > > we have a trigger on an update_date field - pretty simple: > > create trigger "informix".t_upd_comment update of > id,from_class_id,from_id,type_cid,status_cid,seq_num,comment,update_version,created_by,create_date,updated_by > on "informix".comment referencing new as new for each row > ( > update "informix".comment set "informix".comment.update_date = > CURRENT year to fraction(3) where (id = new.id ) ); > > the issue is developers using a JPA tool called Hibernate, which > automatically includes every field in their update sql generated by > the tool - apparently they have no control over it and cannot exclude > this one update_date field, so the update trigger i have on the field > gets fired off and stuck in a loop when their sql does the same? > they are asking if their is a way to tweak out trigger so it is like > an after update trigger, that their sql would update that field, and > our trigger would just "re-update" the same field afterwards and not > got in the updating loop. > > thanks in advance > tom I'm using NHibernate (.NET prot of Hibernate). Feature named "dynamic update" is just exactly what you need - only changed fields are updated. I don't know if JPA also have this feature. Robert