On 23/04/14 17:00, [email protected] wrote:
Date: Wed, 23 Apr 2014 17:54:27 +0700
From: Dan Kennedy<[email protected]>
To:[email protected]
Subject: Re: [sqlite] Trigger cascade/nesting
Message-ID:<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 04/23/2014 05:05 PM, Peter Hardman wrote:
>Hi,
>
>Is there a way of preventing triggers cascading?
>
>I have a table where I need to set a timestamp field when a new record
>is INSERTED. The table uses an auto-increment key field so a BEFORE
>INSERT trigger is ruled out. An AFTER INSERT trigger which UPDATEs the
>new row solves that problem, but I have a second, AFTER UPDATE,
>trigger on the table to save an audit record when the table is
>updated. I need a way of preventing the AFTER UPDATE trigger running
>as a result of the UPDATE command in the AFTER INSERT trigger.
>
>Is this possible? I thought a SELECT RAISE(IGNORE) in the AFTER INSERT
>trigger would do the trick, but it has no effect. I have recursive
>triggers disabled.
>
<snip>
>
You could try:
CREATE TRIGGER audit_test_a_audit_update
AFTER UPDATE OF (all-columns-except-last_changed) ON ...
Dan.
Thanks Dan, that was exactly what I needed. I'd overlooked that.
Igor, thanks for your suggestion, but I'm using a trigger partly to
prevent the user faking the timestamp.
Pete
--
Peter Hardman
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users