开发者

Problem with user defined function

CREATE FUNCT开发者_如何转开发ION testing(id INT, dsc TEXT) RETURNS TEXT
BEGIN
DECLARE ntxt TEXT;
SET ntxt = dsc;
RETURNS ntxt;
END;

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TEXT' at line 3

What i miss here ?


  1. You forgot to change the delimiter
  2. RETURN has an extra S

This does work:

DELIMITER //

CREATE FUNCTION testing(id INT, dsc TEXT) RETURNS TEXT
BEGIN
    DECLARE ntxt TEXT;
    SET ntxt = dsc;
    RETURN ntxt;
END//


You probably forgot to add DELIMITER $$ in the very beginning of your script (Standard delimiter is ;, and it's also used in procedures/functions). For example,

 DELIMITER $$
 [CREATE FUNCTION ...... ]
 $$
 DELIMITER ;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜