MySQL Forums
Forum List  »  Stored Procedures

Statement Only Erros in Procedure
Posted by: Steven Frank
Date: March 22, 2016 03:37PM

I have an update statement that works when run, on it's own, in a query window but is generating a syntax error (missing 'end' in the context of a stored procedure.

This is the statement in question:

UPDATE t_Card c LEFT JOIN t_CardType ct ON c.CardTypeId = ct.CardTypeId SET c.CardType = ct.CardType;

If I remove it from the procedure, no problem, if I run it on it's own, no problem.

Here is the whole code block:

CREATE DEFINER=`myaccount`@`%` PROCEDURE `spUpdateCardType`()
BEGIN
DECLARE cardid char(36);
DECLARE cardsubtype nvarchar(128);

UPDATE t_Card c LEFT JOIN t_CardType ct ON c.CardTypeId = ct.CardTypeId SET c.CardType = ct.CardType;

# Add subtypes
DECLARE updateCur CURSOR FOR
SELECT cxcst.CardId, cst.CardSubType
FROM t_CardXCardSubType cxcst
INNER JOIN t_CardSubType cst ON cxcst.CardSubTypeId = cst.CardSubTypeId
ORDER BY cxcst.CardId, cxcst.xSequence;

OPEN updateCur;

update_loop: LOOP
FETCH updateCur INTO cardid, cardsubtype;

UPDATE t_Card c SET c.CardType = CONCAT(c.CardType, " - ", cardsubtype) WHERE c.CardId = cardid;
END LOOP update_loop;

CLOSE updateCur;
END

Options: ReplyQuote


Subject
Views
Written By
Posted
Statement Only Erros in Procedure
3053
March 22, 2016 03:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.