1
如何在中使用fixed string
作为dynamically generated
的文本?我为这个例子保持简单,但真实的事情很多。所以我不想把它放在这个地方,我想concat
它并把它发送到输出。MySql concat在函数里面使用case时
BEGIN
DECLARE aId INT;
DECLARE aType INT;
DECLARE aParent INT;
DECLARE aUserName VARCHAR(32);
DECLARE aUserId INT;
DECLARE aCountry VARCHAR(2);
DECLARE aOutput VARCHAR(1500);
SELECT id, type, parent INTO aId, aType, aParent FROM products WHERE id = mElmId;
SET aOutput = CASE atype
WHEN 1 THEN 'Something'
WHEN 2 THEN 'Something'
WHEN 3 THEN 'Something'
WHEN 10 THEN
CASE mStatus
WHEN '14' THEN 'Place Order Link'
WHEN '01' THEN 'Cancel Order Link'
WHEN '11' THEN 'Order Cancelled - Place order link'
WHEN '00' THEN 'Order - Under Process'#No link here
WHEN '10' THEN 'Cancel - Under Process' #No link here
ELSE 'Detect Status Error'
END
//I need to concat 'Home ~ More' to the above text, but don't want to add it next to the text above.
//So it ends up like 'Place Order Link ~ Home ~More'
ELSE 'Error generating link'
END;
RETURN (aOutput);
END
调用函数时会传递mStatus。 – Norman
这正是我所希望的。非常感谢您的帮助。 – Norman