List: General Discussion « Previous MessageNext Message » From: nikos Date: December 8 2006 8:26am Subject: RE: Function problem View as plain text
```Thank you for you answer.
I try your suggestion but I'm getting the followin 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 'return
ceil(x+x*0.25)
when x>=50 AND x<100 then ceiling(x+x*0.20)
when x>=100 ' at line 3.

The full syntax is:

DELIMITER \$\$

DROP FUNCTION IF EXISTS `qbit`.`myprice_xondr`\$\$

CREATE FUNCTION `qbit`.`myprice_xondr`(x float(7,2)) RETURNS DECIMAL
BEGIN
CASE x
WHEN (x<50) THEN return ceil(x+x*0.25)
when x>=50 AND x<100 then ceiling(x+x*0.20)
when x>=100 AND x<150 then ceiling(x+x*0.15)
when (x>=150 AND x<200) then (ceiling(x+x*0.10))
when (x>=200) then (ceiling(x+x*0.09))
end case;
END\$\$

DELIMITER ;

-----Original Message-----
From: Chris White [mailto:chriswhite@stripped]
Sent: Thursday, December 07, 2006 6:02 PM
To: mysql@stripped
Subject: Re: Function problem

On Thursday 07 December 2006 04:57, nikos wrote:
> WHEN x<50 THEN ceiling(x+x*0.25)
>
> when x>=50 AND x<100 then ceiling(x+x*0.20)
>
> when x>=100 AND x<150 then ceiling(x+x*0.15)
>
> when (x>=150 AND x<200) then (ceiling(x+x*0.10))
>
> when (x>=200) then (ceiling(x+x*0.09))

You've declared a return value for your function, but it doesn't return
anything, what you probably want is:

> WHEN x<50 THEN return ceiling(x+x*0.25)

and the like for the rest of the cases.

--
Chris White
PHP Programmer
Interfuel

```