15.00 - ABS - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)
Last Update
2018-09-24

ABS

Purpose  

Computes the absolute value of an argument.

Syntax  

where:

 

Syntax element …

Specifies …

arg

a numeric argument.

ANSI Compliance

This is a Teradata extension to the ANSI SQL:2011 standard.

Result Type and Attributes

Here are the default attributes for the result of ABS.

  • If the operand is numeric, the format is the default format for the resulting data type.
  • If the operand is character, the format is the default format for FLOAT.
  • If the operand is a UDT, the format is the default format for the predefined type to which the UDT is implicitly cast.
  • Note: The NULL keyword has a data type of INTEGER.

    For information on data type formats, see SQL Data Types and Literals.

    Argument Types and Rules

    If the argument is not numeric, it is converted to a numeric value, based on implicit type conversion rules. If the argument cannot be converted, an error is reported. For more information on implicit type conversion, see “Implicit Type Conversions” on page 583.

    If arg is a character string, it is converted to a numeric value of the FLOAT data type.

    If arg is a UDT, the following rules apply:

  • The UDT must have an implicit cast to any of the following predefined types:
  • Numeric
  • Character
  • DateTime
  • Interval
  • To define an implicit cast for a UDT, use the CREATE CAST statement and specify the AS ASSIGNMENT clause. For more information on CREATE CAST, see SQL Data Definition Language.

  • Implicit type conversion of UDTs for system operators and functions, including ABS, is a Teradata extension to the ANSI SQL standard. To disable this extension, set the DisableUDTImplCastForSysFuncOp field of the DBS Control Record to TRUE. For details, see Utilities: Volume 1 (A-K).
  • ABS cannot be applied to the following types of arguments:

  • BYTE or VARBYTE
  • BLOB or CLOB
  • CHARACTER or VARCHAR if the server character set is GRAPHIC
  • Examples  

    Representative ABS arithmetic function expressions and the results are as follows.

     

    Expression

    Result

    ABS(-12)

    12

    ABS('23')

    2.30000000000000E+001