SQLitening Support Forum

SQLitening Support => You've got Questions? We've got Answers! => Topic started by: Fim on November 30, 2017, 01:15:27 pm

Title: UPDATE in a TRIGGER
Post by: Fim on November 30, 2017, 01:15:27 pm
This triggers does not work, what am I doing wrong?
CREATE TRIGGER ARB_TRIGG_05 UPDATE OF FK_KOST ON ARB FOR EACH ROW BEGIN UPDATE VOR SET FK_KOSTN_ARB_SUM = FK_KOSTN_ARB_SUM - OLD.FK_KOSTN + NEW.FK_KOSTN WHERE ORDERNR = NEW.ORDERNR; END
I am making a change of FK_KOST in ARB and want change to update an overruled table VOR.
But FK_KOSTN_ARB_SUM in VOR does not update.

/Fim W.
Title: Re: UPDATE in a TRIGGER
Post by: Bern Ertl on December 01, 2017, 10:22:53 am
CREATE TRIGGER ARB_TRIGG_05 AFTER UPDATE ...

Title: Re: UPDATE in a TRIGGER
Post by: Fim on December 01, 2017, 11:16:11 am
Bern,
Many thanks.
I feel a bit stupid as not myself, did not understand it.

/Fim W.
Title: Re: UPDATE in a TRIGGER
Post by: cj on December 01, 2017, 08:46:02 pm
Do you have any of the SQLite books?
The SQL Guide to SQLite by Rick F. van der Lans  978-0-557-07676-5
The Definitive Guild to SQLite by Michael Owns  978-1-59059-673-9

https://www.w3resource.com/sqlite/sqlite-triggers.php

http://www.sqlitetutorial.net/sqlite-trigger/
Title: Re: UPDATE in a TRIGGER
Post by: Fim on December 02, 2017, 07:05:44 am
I have The Definitive Guild to SQLite by Michael Owns and
Using SQLite by Jay A. Kreibich.

Thanks for the tip.
Title: Re: UPDATE in a TRIGGER
Post by: Bern Ertl on December 04, 2017, 11:08:56 am
No worries Fim, took quite a bit of trial and error before I got it too.  SQLites generally doesn't give very helpful feedback (error handling) when you have malformed SQL statements, so it is a bit tricky sometimes to troubleshoot SQL (statement) code.
Title: Re: UPDATE in a TRIGGER
Post by: Fim on December 04, 2017, 06:12:06 pm
Bern,
Thank you for the comforting words.

/Fim W.