T
T
telop2022-02-20 21:49:20
JavaScript
telop, 2022-02-20 21:49:20

How to use "Case when" in "after update" trigger?

I have an "update" trigger that looks like this:

CREATE DEFINER=`root`@`localhost` TRIGGER `Removal_add` BEFORE UPDATE ON `post_cost` FOR EACH ROW BEGIN 
set new.Removal_pl = ((CASE WHEN (select `Poli_csl` from slid where slid.id = new.id)<10 then 
 (select `Model_R_Hr` from rate where rate.id = new.id) * 
 (select `Time_hr` from rate where rate.id = new.id) * 0.3 
 else (select `Model_R_Hr` from rate where rate.id = new.id) * 
 (select `Time_hr` from rate where rate.id = new.id) END));
END


This trigger works for me, but I also want to create an "after update" trigger with the same condition from the trigger above, but I don't know how to do it, so far it gives an error.
The trigger itself:
CREATE TRIGGER post_2
    AFTER UPDATE
    ON slid FOR EACH ROW
    BEGIN 
UPDATE `harld`.`post_cost` set `Removal_pl` = CASE WHEN new.`Poli_csl`  where `id` = new.id < 10 then
 (select `Model_R_Hr` from rate where rate.id = new.id) * 
 (select `Time_hr` from rate where rate.id = new.id) * 0.3 
 else (select `Model_R_Hr` from rate where rate.id = new.id) * 
 (select `Time_hr` from rate where rate.id = new.id) END));
END;

What's wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
Web Developer Blog, 2016-03-19
@L1Qu0R

The second naturally!

R
Roman Rakzin, 2016-03-19
@TwoRS

vue.js is a cool thing. Try it. Like Angular, but a little lighter and faster. There are more stars on the gita, although younger))

S
Super User, 2016-03-19
@sergeystepanov1988

If for myself for the future, with the prospect of working with him in a year or two, then of course the second.
If tomorrow, in a month to work, in a project with angular, then there is most likely the first version. Therefore, it is necessary to learn first.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question