두 개의 트리거가 있습니다. 각각 다음과 같은 트리거가 하나씩 있지만 모두 함께 작동하지 않습니다.두 개의 트리거가 있는데 테이블을 업데이트 할 때 오류가 발생합니다.
어떻게하면 함께 사용할 수 있습니까? 테이블의 다른 필드를 업데이트합니다.
트리거 1
create trigger wys_sk_u after update on `things`
for each row
begin
UPDATE `current` s
INNER JOIN things u ON s.id_thing = u.id_thing
INNER JOIN dude_base b ON b.id= s.id
SET s.`curr_cash` = u.cash1 * b.cash2/ 100;
end;
$$
트리거 2 :
create trigger suma_u after update on `current`
for each row
begin
UPDATE `current`
SET `mysum` = `curr_cash` + `mysum`;
end;
$$
첫 번째 업데이트시기 cash1
또는 cash2
업데이트 및 curr_cash
의 변화 값. curr_cash
이 업데이트되면 두 번째 업데이트해야하며 mysum
을 변경하십시오. 나는 테이블 것들을 편집 오류 다음있어
:
#1442 - Can't update table 'current' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
@edit 는 질문에 새로운 answear을 추가했다.
내가 이런 일을 수행하려는 경우 :
CREATE TRIGGER total BEFORE UPDATE ON `current` FOR EACH ROW
BEGIN
if new.`new_pay_date` <> old.`new_pay_date`
SET new.`total_cash` = new.`curr_cash` + new.`total_cash`;
end if;
END;
$$
오류 : 나는 이것을 확인해야
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET new.`total_cash` = new.`curr_cash` + new.`total_cash`; end if;' at line 4
이
if new.`new_pay_date` <> old.`new_pay_date`
end if;
없이 작업했다 그러나 날짜 변경으로 만 업데이트됩니다.
현재 테이블 :
curr_cash
new_pay_date
id_person
id_thing
total_cash
사람이 하나가 나를 도울 수?
감사합니다. – trinny