On 12/31/2014 9:48 PM, Dâniel Fraga wrote:
        3) create a TRIGGER using INSTEAD OF:

CREATE TRIGGER [BTC_BRL-TRIGGER] INSTEAD OF INSERT
ON [BTC_BRL-VIEW]

WHEN (SELECT last_price FROM [BTC_BRL-VIEW] WHERE
last_price != new.last_price)

BEGIN INSERT INTO [BTC_BRL] values(new.timestamp,new.last_price);
END;

        4) finally try to INSERT:

INSERT INTO [BTC_BRL-VIEW] values(1419991328,925.47);

        The INSERT will execute, but the table [BTC_BRL] remains empty.

Well, the WHEN condition on the trigger is always false when the table is empty. What else did you expect?

Perhaps you meant something like

WHEN new.last_price NOT IN (SELECT last_price ...)

--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to