Name

number — coerce a string or numeric argument to a numeric value

Synopsis

numeric number( in value any);
 

Description

number is the SQL-callable implementation of the XPath 1.0 number() conversion function. It returns its argument coerced to a numeric value:

  • Integer, float, double and numeric inputs are returned unchanged (as a fresh box).

  • String inputs are parsed: short integer-shaped strings (< 10 chars, no ., no e) become integers; otherwise the value is parsed as a numeric, and finally as a double if neither succeeds.

  • Anything else, or a string that cannot be parsed, raises SQL state XM001.

For the XPath/XSLT/XQuery number() function (used inside XPath expressions and XSLT stylesheets) see the XPath function reference entry.

Return Values

A numeric value (integer, double precision, or numeric) depending on the parsed form of the input.

Errors

Table 24.119. Errors signalled by number

SQLState Error Text Description
XM001 can't convert string to number in number () The string argument could not be parsed as any numeric form.
XM001 not a string or number for number () The argument was neither a numeric nor a string.


© 1992 - OpenLink Software. All rights reserved.

Making Technology Work for You®