1

几个小时以来,我一直试图找出我的错误,但一无所获。所以这是我的功能:

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

4

1 回答 1

1
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 ;
于 2013-09-26T15:13:53.910 回答