CREATE FUNCTION CharValIsNumeric (v VARCHAR(15))

    RETURNS boolean

BEGIN

    declare i, l int(2);

    set l=char_length(v);

    set i=1;

    while (i <= l) and (substring(v,i,1) in
('1','2','3','4','5','6','7','8','9','0')) do

        set i=i+1;

    end while;

What if the string (v) doesn't contain a number or is null?

I'm guessing that's your problem - it's getting into that while loop and never able to get out.

Maybe you're better off using a regular expression here:

http://dev.mysql.com/doc/refman/5.1/en/regexp.html
http://dev.mysql.com/doc/refman/5.1/en/pattern-matching.html
http://dev.mysql.com/doc/refman/5.1/en/string-comparison-functions.html

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to