Click here to Skip to main content
15,914,162 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in this function it gives me an Error Like
MySQL Database Error: 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 'WHILE label1;

SQL
DROP FUNCTION IF EXISTS ExtractInteger;

CREATE FUNCTION ExtractInteger ( _String VARCHAR(20) )
RETURNS INT
BEGIN
SET @Count = 0;
SET @IntNumbers = '';

   label1: WHILE (@Count <= LEN(_String)) DO
    IF (SUBSTRING(_String,@Count,1) >= '0' AND SUBSTRING(_String,@Count,1) <= '9') then
    begin
    SET @IntNumbers = @IntNumbers + SUBSTRING(_String,@Count,1);
    end;
     SET @Count = (@Count + 1);
   END WHILE label1;

   RETURN @IntNumbers;

END;
Posted
Comments
Richard MacCutchan 30-Dec-14 5:42am    
What version of MySQL are you using?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900