ABS or ABSVAL scalar function

The ABS function returns the absolute value of a number.

Read syntax diagramSkip visual syntax diagramABSABSVAL( numeric-expression)

The schema is SYSIBM.

The argument must be an expression that returns a value of any built-in numeric data type.

The arguments can also be a character string or graphic string data type. The string input is implicitly cast to a numeric value of DECFLOAT(34).

The result of the function has the same data type and length attribute as the argument.

The result can be null; if the argument is null, the result is the null value.

Notes

Syntax alternatives:
ABS should be used for conformance to the SQL standard.

Example

Assume that host variable PROFIT is a large integer with a value of -50000. The following statement returns a large integer with a value of 50000.
   SELECT ABS(:PROFIT)
     FROM SYSIBM.SYSDUMMY1;