开发者

Problem with user defined function

开发者 https://www.devze.com 2023-01-26 07:08 出处:网络
CREATE FUNCT开发者_如何转开发ION testing(id INT, dsc TEXT) RETURNS TEXT BEGIN DECLARE ntxt TEXT;
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

精彩评论

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