MySQL Forums
Forum List  »  Triggers

Why isn't this working?
Posted by: John Frank
Date: April 13, 2021 11:54AM

Hey Everyone,
I am working on a database, and I want to set up a trigger. Here is the last outline of the two tables

Lighting:
|Index | col1 | col2 | Last Updated|
------------------------------------
|1     |info  |info. | 1618335050  |


Lighting Schedule:
|Index | time  | strength |
---------------------------
|1     |12:00  |0         |
---------------------------
|2     |13:00. |20        |
---------------------------
|3     |13:15. |25        |
---------------------------
|2     |13:40. |50        |

I have a python program that will delete all the rows in `Lighting Schedule` and replace insert new information. What I am looking for is a trigger that put a timestamp into row one column "Last Updated" in the `Lighting` table when that happens

The code below keeps shooting back a generic error.

Any ideas?


DELIMITER $$
CREATE TRIGGER 'LightingLastUpdated'
AFTER INSERT
ON `Lighting Schedule`
BEGIN
	UPDATE `Lighting` SET `Last Updated` = TIMESTAMP WHERE 'Index' = 1;
END$$

DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
Why isn't this working?
216
April 13, 2021 11:54AM
90
April 13, 2021 02:54PM
68
April 14, 2021 09:24AM
73
April 14, 2021 09:54AM
81
April 14, 2021 10:26AM
73
April 14, 2021 02:06PM
94
April 14, 2021 04:06PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.