A
A
Andrey Pushkin2018-05-20 18:42:21
MySQL
Andrey Pushkin, 2018-05-20 18:42:21

I made a trigger, but it does not work, how to fix it?

I made this kind of trigger:

CREATE TRIGGER bonus
AFTER INSERT ON `personal` FOR EACH ROW
UPDATE personal SET cash = 10000 + NEW.cash;

The idea is that when I add a new employee to the personal table, and put down the salary in cash, a bonus of 10000 is added to him.
The trigger was created, but when adding a new employee to the table, an error occurs
Operation failed: There was an error while applying the SQL script to the database.
ERROR 1442: 1442: Can't update table 'personal' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2018-05-20
@a_pussycan

CREATE TRIGGER bonus
BEFORE INSERT ON `personal` FOR EACH ROW
SET NEW.cash = 10000 + NEW.cash;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question