Results 1 to 3 of 3

Thread: isnumeric

  1. #1
    Join Date
    Jul 2003
    Posts
    23

    Question Unanswered: isnumeric

    Is there an informix equivalent to the function isnumeric() ?

  2. #2
    Join Date
    May 2004
    Location
    New York
    Posts
    248
    I don't think there is one, but you can create it very easily
    using someting like

    LET charstr = integer value

    FOR i = 1 to LENGTH(charstr)
    IF charstr[i] in (1,2,3,4 etc... ) THEN
    -- do nothing
    ELSE
    ERROR "Not a numberic value"
    RETURN FALSE
    END IF
    END FOR

    I did not try it, Do not have access to 4gl but should work

  3. #3
    Join Date
    Apr 2003
    Location
    Phoenix, AZ
    Posts
    177
    This is what we use:

    drop function isnumeric;
    create function isnumeric(inputstr char(12)) returning integer;
    define numeric_var decimal(12,6);
    define function_rtn integer;

    on exception in (-1213)
    let function_rtn = 0;
    end exception with resume

    let function_rtn = 1;
    let numeric_var = inputstr;

    return function_rtn;
    end function;


    Fuction returns a "1" if numeric, "0" if non-numeric. I'm just trapping the numeric conversion error.
    Fred Prose

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •