This is a discussion on create function within the MySQL Database forums, part of the Database Forums category; I am trying to create the following function to loop through the characters of an input string. If even one ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am trying to create the following function to loop through the
characters of an input string. If even one of the characters is not a '4' then return true, or else I want it to return false. Here is the error message I keep getting: "Script line: 2 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 'SET vindex = vindex + 1; END WHILE RETURN vcount; END' at line 18" Here is the function: delimiter $ create function testChar (input VARCHAR(100)) RETURNS BOOLEAN BEGIN DECLARE inputlength INT; DECLARE vindex INT; DECLARE vcount BOOLEAN; SET vcount = FALSE; SET vindex = 1; SET inputlength = LEN(input); WHILE (vindex <= inputlength) DO IF SUBSTRING(input, vindex, 1) != '4' THEN SET vcount = TRUE; RETURN vcount; END IF SET vindex = vindex + 1; END WHILE RETURN vcount; END |
|
|||
|
On 23 Apr 2007 11:47:25 -0700, drhinehart@gmail.com wrote:
> >WHILE (vindex <= inputlength) DO > IF SUBSTRING(input, vindex, 1) != '4' THEN > SET vcount = TRUE; > RETURN vcount; > END IF > SET vindex = vindex + 1; >END WHILE > >RETURN vcount; > >END END IF ; END RETURN ; The end shall be ;-ed. It's written in the bible. |