im stuck on calling stored procedures inside a SELECT CASE on a Trigger, it gaves me the following error:
[Err] 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 'empata(NEW.eqvis))
WHEN 'loc' THEN pierde(NEW.eqvis)
WHEN 'vis' THEN g' at line 16
Here is the code:
DELIMITER |
CREATE TRIGGER updpartido AFTER UPDATE ON partidos
FOR EACH ROW
BEGIN
SET @vgls = vgoles(NEW.eqvis);
SET @lgls = vgoles(NEW.eqloc);
SET @vglsec = vgolesec(NEW.eqvis);
SET @lglsec = vgolesec(NEW.eqloc);
SELECT CASE
WHEN @vgls=@lgls THEN "emp"
WHEN @vgls>@lgls THEN "loc"
WHEN @vgls<@lgls THEN "vis"
END
INTO @st;
SELECT CASE @st
WHEN 'emp' THEN CALL empata(NEW.eqvis)
WHEN 'loc' THEN CALL pierde(NEW.eqvis)
WHEN 'vis' THEN CALL gana(NEW.eqvis)
END
INTO @dat;
SELECT CASE @st
WHEN 'emp' THEN CALL empata(NEW.eqloc)
WHEN 'vis' THEN CALL pierde(NEW.eqloc)
WHEN 'loc' THEN CALL gana(NEW.eqloc)
END
INTO @dat2;
UPDATE equipos SET gf=@vgls,gc=@vglsec WHERE id=NEW.eqvis;
UPDATE equipos SET gf=@lgls,gc=@lglsec WHERE id=NEW.eqloc;
END;
|
But if i remove the "CALL" the Triggers adds but when i do some update it gives me the error of "FUNCTION not found" since i made them as stored procedures and not as functions because im not going to return nothing...
Any help is very appreciated!