jfbaro <jeanfautrix-/E1597aS9LRfJ/[EMAIL PROTECTED]> wrote:
We need to use a trigger to update the column sync into a table when
any column is changed (except the sync column itself), so by looking
in the SQLite website we came across that:

CREATE TRIGGER syncTransactions AFTER
UPDATE OF transactionId, transactionJourneyId, transactionDeviceId,
transactionSignificant ON transactions
BEGIN
 UPDATE transactions SET sync = 0 WHERE transactionId =
old.transactionId; END;

But even when we change sync column (by issuing a update command on
SQLite Expert tool) the trigger is executed. Shouldn't it be execute
only when we update one of the columns specified in the clause UPDATE
OF??

Another question, is it possible to have in the UPDATE OF clause
something like "ALL BUT sync"?? So if we add new columns to that
table we wouldn't need to change the trigger. (I don't thing that is
possible though).

Something like this perhaps:

CREATE TRIGGER syncTransactions
   AFTER UPDATE ON transactions
BEGIN
 UPDATE transactions SET sync = 0
 WHERE transactionId = old.transactionId and new.sync = old.sync;
END;

I wonder about (transactionId = old.transactionId) condition: if transactionId itself is updated, the row with old.transactionId probably doesn't exist anymore. Don't you want to update one matching new.transactionId ?

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to