View Single Post
Old 07-19-2012, 04:07 AM   #46
snarkophilus
Wannabe Connoisseur
snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.snarkophilus ought to be getting tired of karma fortunes by now.
 
Posts: 425
Karma: 2516674
Join Date: Apr 2011
Location: Geelong, Australia
Device: Kobo Libra 2, Kobo Aura 2, Sony PRS-T1, Sony PRS-350, Palm TX
Quote:
Originally Posted by pssquirrel View Post
Thanks Snarkophilus (and jackie_w, who has been helping me via PM). Unfortunately, the semi-colon and / didn't help.

But after some experimenting, I discovered that if I change the pull-down menu from "UPDATE OF" to simply "UPDATE" (see attached screenshot) the trigger will save without error. However, the resulting trigger code is different!!! than Kolenka's original code. Here's what I end up with:

CREATE TRIGGER recently_opened_trigger AFTER UPDATE ON books BEGIN UPDATE books SET added_date = 0 WHERE _id = new._id;
UPDATE books SET added_date = reading_time WHERE reading_time NOT NULL AND _id <> new._id;
END

With not a little trepidation, I loaded this new db on my T1 and it appears to work (really?!), but since I know nothing about SQL, I'm worried my altered code is going to back-fire on me.

What think? Have I done something foolish or stupid?
I'm worried that the above trigger will update the added_date every time a record is changed, instead of just when the reading_time value of a record is changed. The problem is that I'm not sure when else a record is updated.

At worst, you might find that some books mysteriously jump to the top of your recently opened list. At best, you won't notice a thing . Either way, I don't think that trigger will cause any damage.

Cheers,
Simon.
snarkophilus is offline   Reply With Quote