开发者

MySQL CReate Function Syntax Error

开发者 https://www.devze.com 2023-01-25 16:58 出处:网络
I\'m trying to create function using phpmyadmin/mysql console. Without any luck. I\'m getting info of syntax error.

I'm trying to create function using phpmyadmin/mysql console. Without any luck. I'm getting info of syntax error.

Can anybody take a look on this function?

CREATE FUNCTION fnCategoryList
(
    @NewsID INT
)
RETURNS VARCHAR(1000)
AS
BEGIN
    DECLARE @CategoryList VARCHAR(1000)
    SET @CategoryList = ''

    SELECT @CategoryList = COALESCE(@CategoryList + ',','') + C.[Name]
        FROM news_开发者_C百科categories AS NC
            INNER JOIN categories AS C
                ON NC.CategoryID = C.ID
        WHERE NC.NewsID = @NewsID

    RETURN @CategoryList
END


This is not correct syntax for a MySQL function. That's why you get a syntax error.

http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html

Did you try to copy this from a different RDBMS?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号