Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I keep receiving an error with the following code. I am trying to make a function that will format a field (content=0.0032) into a varchar/percent (content=0.32%). At the moment I'm just trying to get format to work, and it throws up an error:

"Error Code : 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 'len);"

The function definition for "Format" is "Format(X,d)" where x is the number and d is the number of decimal places to round too. It then should output a string ###,###,###.## etc.

My code is as follows:

DROP FUNCTION IF EXISTS percent;
DELIMITER $$

CREATE
    /*[DEFINER = { user | CURRENT_USER }]*/
    FUNCTION `auau7859_aba`.`percent`(num DOUBLE, len INT)
    RETURNS VARCHAR(10)
    DETERMINISTIC

    BEGIN
       RETURN FORMAT(num,len);
    END$$

DELIMITER ;
share|improve this question

closed as too localized by Jocelyn, Bill the Lizard Apr 24 '13 at 2:43

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
I don't see that error. I can define the function and use it without problems. Right now it's just a wrapper around format() though. –  Alexandre Jasmin Mar 31 '10 at 3:15
add comment