SQLitening Support Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the SQLitening support forums!

Author Topic: UPDATE in a TRIGGER  (Read 417 times)

Fim

  • Guru
  • ***
  • Posts: 139
    • View Profile
    • Fims sajt
UPDATE in a TRIGGER
« on: November 30, 2017, 11:45:27 AM »

This triggers does not work, what am I doing wrong?
Code: [Select]
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; ENDI 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.
Logged
Fim W

Bern Ertl

  • Master Geek
  • ****
  • Posts: 481
  • Excellent
    • View Profile
    • InterPlan Systems
Re: UPDATE in a TRIGGER
« Reply #1 on: December 01, 2017, 08:52:53 AM »

CREATE TRIGGER ARB_TRIGG_05 AFTER UPDATE ...

Fim

  • Guru
  • ***
  • Posts: 139
    • View Profile
    • Fims sajt
Re: UPDATE in a TRIGGER
« Reply #2 on: December 01, 2017, 09:46:11 AM »

Bern,
Many thanks.
I feel a bit stupid as not myself, did not understand it.

/Fim W.
Logged
Fim W

cj

  • Master Geek
  • ****
  • Posts: 636
    • View Profile
Re: UPDATE in a TRIGGER
« Reply #3 on: December 01, 2017, 07:16: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/

Fim

  • Guru
  • ***
  • Posts: 139
    • View Profile
    • Fims sajt
Re: UPDATE in a TRIGGER
« Reply #4 on: December 02, 2017, 05:35:44 AM »

I have The Definitive Guild to SQLite by Michael Owns and
Using SQLite by Jay A. Kreibich.

Thanks for the tip.
Logged
Fim W

Bern Ertl

  • Master Geek
  • ****
  • Posts: 481
  • Excellent
    • View Profile
    • InterPlan Systems
Re: UPDATE in a TRIGGER
« Reply #5 on: December 04, 2017, 09:38: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.

Fim

  • Guru
  • ***
  • Posts: 139
    • View Profile
    • Fims sajt
Re: UPDATE in a TRIGGER
« Reply #6 on: December 04, 2017, 04:42:06 PM »

Bern,
Thank you for the comforting words.

/Fim W.
Logged
Fim W