I found a solution to a problem I reported here:
http://stackoverflow.com/questions/27711987/sqlite-insert-only-if-price-is-different-from-last-row/
And I notice an SQLite abnormal behaviour (I'm using version
3.8.7.4). Here's how you can reproduce it:
1) create a TABLE and leave it empty:
CREATE TABLE IF NOT EXISTS [BTC_BRL](timestamp integer,
last_price real);
2) create a VIEW with the last row:
CREATE VIEW [BTC_BRL-VIEW] AS SELECT timestamp,last_price
FROM [BTC_BRL] order by rowid desc limit 1;
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.
The INSERT will only work when we INSERT at least an entry into table
[BTC_BRL] directly.
Can someone confirm this?
Thank you!
--
Linux 3.18.1: Diseased Newt
http://www.youtube.com/DanielFragaBR
http://exchangewar.info
Bitcoin: 12H6661yoLDUZaYPdah6urZS5WiXwTAUgL
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users