簡體   English   中英

創建功能時出現MySQL語法錯誤

[英]MySQL syntax error on FUNCTION creation

數小時以來,我一直在尋找錯誤,但一無所獲。 所以這是我的功能:

DELIMITER //
DROP FUNCTION IF EXISTS func_name//
CREATE FUNCTION func_name(_num_client INT) RETURNS VARCHAR(20)
BEGIN
DECLARE n_titul VARCHAR(20) DEFAULT NULL;
SET n_titul = (SELECT UPPER(
    IF(
        length(concat_ws(' ', civilite, prenom, nom)),
        IF(
            length(concat_ws(' ', civilite, concat(substring(prenom, 1, 1), '.'), nom)),
            substring(concat_ws(' ', civilite, concat(substring(prenom, 1, 1), '.'), nom), 1, 20),
            concat_ws(' ', civilite, concat(substring(prenom, 1, 1), '.'), nom)
        ),
        concat_ws(' ', civilite, prenom, nom)
    )
) FROM client WHERE num_client=_num_client) ;
RETURN n_titul;
END;
//

我得到這個回應:

ERROR: Punctuation invalid @ 637 STR: // SQL: { HERE THE RESQUEST ABOVE }

#1064 - 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 '//' at line 17

DELIMITER //
DROP FUNCTION IF EXISTS func_name//
CREATE FUNCTION func_name(_num_client INT) RETURNS VARCHAR(20)
BEGIN
DECLARE n_titul VARCHAR(20) DEFAULT NULL;
SET n_titul = (SELECT UPPER(
    IF(
        length(concat_ws(' ', civilite, prenom, nom)),
        IF(
            length(concat_ws(' ', civilite, concat(substring(prenom, 1, 1), '.'), nom)),
            substring(concat_ws(' ', civilite, concat(substring(prenom, 1, 1), '.'), nom), 1, 20),
            concat_ws(' ', civilite, concat(substring(prenom, 1, 1), '.'), nom)
        ),
        concat_ws(' ', civilite, prenom, nom)
    )
) FROM client WHERE num_client=_num_client) ;
RETURN n_titul;
END//
DELIMITER ;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM