我正在将它从 mssql 转换为 mysql,但它给了我这个错误:
错误代码:1415 不允许从函数返回结果集
我究竟做错了什么?
DELIMITER $$
CREATE FUNCTION GetPositionList (orderDetID NUMERIC)
RETURNS NVARCHAR(200)
DETERMINISTIC
BEGIN
DECLARE strToReturn NVARCHAR(50);
DECLARE strPos NVARCHAR(50);
DECLARE strPosOtherRes NVARCHAR(50);
DECLARE strTPos NVARCHAR(50);
DECLARE strTPosOtherResr NVARCHAR(50)
SET strToReturn = '';
SET strPos = SELECT `POSITION` FROM orderdetails WHERE OrderID = orderDetID;
SET strPosOtherRes = SELECT SecPosition FROM orderdetails WHERE OrderID = orderDetID;
SET strTPos = SELECT TeamPosition FROM orderdetails WHERE OrderID = orderDetID;
SET strTPosOtherResr = SELECT TeamSecPosition FROM orderdetails WHERE OrderID = orderDetID;
IF(strPos != '') THEN SET strToReturn = CONCAT(strPos , ',');
END IF;
IF(strPosOtherRes != '' ) THEN SET strToReturn = CONCAT(strToReturn , strPosOtherRes , ',');
END IF;
IF(strTPos != '' ) THEN SET strToReturn = CONCAT(strToReturn , strTPos , ',');
END IF;
IF(strTPosOtherResr != '' ) THEN SET strToReturn = CONCAT(strToReturn , strTPosOtherResr , ',');
END IF;
RETURN SUBSTRING( strToReturn, 0, LENGTH(strToReturn) );
END $$
DELIMITER ;