Caché SQL Reference
ISNUMERIC
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   
Search:    

A numeric function that tests for a valid number.
Synopsis
ISNUMERIC(check-expression)
Arguments
check-expression The expression to be evaluated.
Description
ISNUMERIC evaluates check-expression and returns one of the following values:
ISNUMERIC generates an SQLCODE -7, exponent out of range error if a scientific notation exponent is greater than 308 (308 – (number of integers - 1)). For example, ISNUMERIC(1E309) and ISNUMERIC(111E307) both generate this error code. If an exponent numeric string less than or equal to '1E145' returns 1; an exponent numeric string greater than '1E145' returns 0.
The ISNUMERIC function is very similar to the ObjectScript $ISVALIDNUM function. However, these two functions return different values when the input value is NULL.
Examples
In the following example, all of the ISNUMERIC functions return 1:
SELECT ISNUMERIC(99) AS MyInt,
       ISNUMERIC('-99') AS MyNegInt,
       ISNUMERIC('-0.99') AS MyNegFrac,
       ISNUMERIC('-0.00') AS MyNegZero,
       ISNUMERIC('-0.09'+7) AS MyAdd,
       ISNUMERIC('5E2') AS MyExponent
 
The following example returns NULL if FavoriteColors is NULL; otherwise, it returns 0, because FavoriteColors is not a numeric field:
SELECT Name,
ISNUMERIC(FavoriteColors) AS ColorPref
FROM Sample.Person
 
See Also