On Sat, Jan 08, 2011 at 12:07:08PM +0700, Dan Kennedy wrote:
> On 01/08/2011 08:12 AM, Nicolas Williams wrote:
> > I need to use recursive triggers. In some cases I want to "normalize"
> > values of some columns of NEW being INSERTed or UPDATEd, but there's no
> > UPDATE syntax for changing NEW, thus I can't write something like:
> >
> > [...]
> >
> > I must write:
> >
> > CREATE TRIGGER ...
> > BEGIN
> > UPDATE SET somecol = ()
> > WHERE rowid = NEW.rowid;
> > END;
>
> Something like this perhaps:
>
> CREATE TRIGGER sometrig AFTER UPDATE WHEN somecol != BEGIN
>UPDATE sometab SET somecol = WHERE rowid = NEW.rowid;
> END;
Yes, adding a WHEN clause to the triggers also works.
I did have some triggers with WHEN clauses, actually, but it didn't
occur to me to use that as a technique for breaking recursion in part, I
think, because the WHEN expression would, in this case, be several lines
long, and aesthetically that rubbed me the wrong way. I've got several
instances of that sort of expression in my code and it occurs to me that
I can use additional views to reduce the length of that expression.
Thanks to Dan as well. CHeers,
Nico
--
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users