docs.intersystems.com
Home / InterSystems SQL Reference / SQL Functions / ISNUMERIC

InterSystems SQL Reference
ISNUMERIC
Previous section           Next section
InterSystems: The power behind what matters   
Search:  


A numeric function that tests for a valid number.
Synopsis
ISNUMERIC(check-expression)
Arguments
check-expression The expression to be evaluated.
ISNUMERIC returns the SMALLINT data type.
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


Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-06-18 10:52:35