0

Grettings everyone, im trying to create a stored procedure but it gives me the following error:

1339 Case not found for CASE statement

Here is the code:

BEGIN
	#Routine body goes here...
	CASE @olds
	WHEN 'emp' THEN
		CASE @news
		WHEN 'loc' THEN
			UPDATE equipos SET pe=pe-1,pg=pg+1 WHERE id=@eqloc;
			UPDATE equipos SET pe=pe-1,pp=pp+1 WHERE id=@eqvis;
			UPDATE partidos SET `eqgan`=@news WHERE id=@mst;
			UPDATE log_partidos SET `status`=@news WHERE `match`=@mst;
		WHEN 'vis' THEN
			UPDATE equipos SET pe=pe-1,pg=pg+1 WHERE id=@eqvis;
			UPDATE equipos SET pe=pe-1,pp=pp+1 WHERE id=@eqloc;
			UPDATE partidos SET `eqgan`=@news WHERE id=@mst;
			UPDATE log_partidos SET `status`=@news WHERE `match`=@mst;
		END CASE;
	WHEN 'loc' THEN
		CASE @news
		WHEN 'emp' THEN
			UPDATE equipos SET pe=pe+1,pg=pg-1 WHERE id=@eqloc;
			UPDATE equipos SET pe=pe+1,pp=pp-1 WHERE id=@eqvis;
			UPDATE partidos SET `eqgan`=@news WHERE id=@mst;
			UPDATE log_partidos SET `status`=@news WHERE `match`=@mst;
		WHEN 'vis' THEN
			UPDATE equipos SET pp=pp-1,pg=pg+1 WHERE id=@eqvis;
			UPDATE equipos SET pg=pg-1,pp=pp+1 WHERE id=@eqloc;
			UPDATE partidos SET `eqgan`=@news WHERE id=@mst;
			UPDATE log_partidos SET `status`=@news WHERE `match`=@mst;
		END CASE;
	WHEN 'vis' THEN
		CASE @news
		WHEN 'emp' THEN
			UPDATE equipos SET pe=pe+1,pg=pg-1 WHERE id=@eqvis;
			UPDATE equipos SET pe=pe+1,pp=pp-1 WHERE id=@eqloc;
			UPDATE partidos SET `eqgan`=@news WHERE id=@mst;
			UPDATE log_partidos SET `status`=@news WHERE `match`=@mst;
		WHEN 'loc' THEN
			UPDATE equipos SET pp=pp-1,pg=pg+1 WHERE id=@eqloc;
			UPDATE equipos SET pg=pg-1,pp=pp+1 WHERE id=@eqvis;
			UPDATE partidos SET `eqgan`=@news WHERE id=@mst;
			UPDATE log_partidos SET `status`=@news WHERE `match`=@mst;
		END CASE;
	END CASE;
END

What im doing wrong?
My parameters are those:

IN `mst` varchar(3),IN `olds` varchar(3),IN `news` varchar(3),IN `eqloc` int,IN `eqvis` int

Edited by apatuka: n/a

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by smantscheff
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.