vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello list. Can somebody tells what's wrong with this fuction? DELIMITER $$ DROP FUNCTION IF EXISTS `qbit`.`myprice_xondr`$$ CREATE FUNCTION `qbit`.`myprice_xondr`(x float(7,2)) RETURNS float(7,2) BEGIN CASE x 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)) end case; END$$ DELIMITER ; Thanx Nikos |
| |||
| 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 |
| |||
| 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@interfuel.com] Sent: Thursday, December 07, 2006 6:02 PM To: mysql@lists.mysql.com 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 |
| ||||
| nikos wrote: > 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@interfuel.com] > Sent: Thursday, December 07, 2006 6:02 PM > To: mysql@lists.mysql.com > 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. > Is your column `ceil` or `ceiling`? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| Thread Tools | |
| Display Modes | |
|
|