So I am running into an issue when executing this procedure. It runs properly by deleting the materials and creating a new item "HBlade", but at the very end, it isn't setting the argOutMessage to "Completed successfully. HBlade has been forged." Instead, the outmessage is writing as "Aborted: Need 1 Cblade" which is one of the tests at the beginning of the command.
Any idea on why this may be happening? Am I missing some syntax somewhere? It is perplexing me -- I would like a successful completion to end with the proper OutMessage and not have the command start over upon completion.
Thanks in advance.
WHEN 'HBLADE' THEN
BEGIN
SELECT `Amount` INTO prAC FROM `funds` WHERE `CharacterID` = argCharID;
IF prAC < 20
THEN
BEGIN
set argOutMessage = 'Aborted: not enough AC.';
leave main_block;
END;
END IF;
SELECT `Contribution` INTO prContribution FROM `character` WHERE `CharacterID` = argCharID;
IF prContribution < 50
THEN
BEGIN
set argOutMessage = 'Aborted: not enough contribution.';
leave main_block;
END;
END IF;
IF ((SELECT COUNT(*) FROM `item` WHERE `CharID` = argCharID AND `Name` = 'CBlade') != 1) THEN
BEGIN
SET argOutMessage = "Aborted: need 1 CBlade";
leave main_block;
END;
END IF;
IF ((SELECT COUNT(*)
FROM `item`
WHERE `CharID` = argCharID AND `Name` IN ('LBlade', 'DExe')
) <> 1)
THEN
SET argOutMessage = 'Aborted: need 1 LBlade or DExe';
leave main_block;
END IF;
UPDATE `funds`
SET `Amount` = `Amount` - 20
WHERE `CharacterID` = argCharID;
UPDATE `character`
SET `Contribution` = `Contribution` - 50
WHERE `CharacterID` = argCharID;
DELETE FROM `item` WHERE `CharID` = argCharID AND `Name` IN ('CBlade', 'LBlade', 'DExe');
SET prID1 = FLOOR(-30000+60000*RAND());
SET prID2 = FLOOR(-30000+60000*RAND());
SET prID3 = FLOOR(-30000+60000*RAND());
INSERT INTO `item`(`CharID`, `Name`, `ItemID`, `Count`, `Type`, `ID1`, `ID2`, `ID3`, `Color`, `Effect1`, `Effect2`, `Effect3`, `LifeSpan`, `Attribute`, `Equip`, `X`, `Y`)
VALUES (argCharID, 'HBlade', 1419, 1, 2, prID1, prID2, prID3, 9, 0, 0, 0, 15000, 0, 0, 0, 0);
SET argOutMessage = "Completed successfully. HBlade has been forged.";
leave main_block;
END;