DB2 10.5 for Linux, UNIX, and Windows

BIGINT scalar function

The BIGINT function returns a 64-bit integer representation of a number, a string representation of a number, or a datetime value.

Numeric to Big Integer

Read syntax diagramSkip visual syntax diagram
>>-BIGINT--(--numeric-expression--)----------------------------><

String to Big Integer

Read syntax diagramSkip visual syntax diagram
>>-BIGINT--(--string-expression--)-----------------------------><

Datetime to Big Integer

Read syntax diagramSkip visual syntax diagram
>>-BIGINT--(--datetime-expression--)---------------------------><

The schema is SYSIBM.

Numeric to Big Integer

numeric-expression
An expression that returns a value of any built-in numeric data type.

The result is the same number that would occur if the argument were assigned to a big integer column or variable. The fractional part of the argument is truncated. If the whole part of the argument is not within the range of big integers, an error is returned (SQLSTATE 22003).

String to Big Integer

string-expression
An expression that returns a value that is a character-string or Unicode graphic-string representation of a number with a length not greater than the maximum length of a character constant.

The result is the same number that would result from CAST(string-expresssion AS BIGINT). Leading and trailing blanks are eliminated and the resulting string must conform to the rules for forming an integer, decimal, floating-point, or decimal floating-point constant (SQLSTATE 22018). If the whole part of the argument is not within the range of big integers, an error is returned (SQLSTATE 22003). The data type of string-expresssion must not be CLOB or DBCLOB (SQLSTATE 42884).

Datetime to Big Integer

datetime-expression
An expression that is of one of the following data types:
  • DATE. The result is a BIGINT value representing the date as yyyymmdd.
  • TIME. The result is a BIGINT value representing the time as hhmmss.
  • TIMESTAMP. The result is a BIGINT value representing the timestamp as yyyymmddhhmmss. The fractional seconds portion of the timestamp value is not included in the result.

The result of then function is a big integer. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Notes

Examples

  • Example 1: From ORDERS_HISTORY table, count the number of orders and return the result as a big integer value.
       SELECT BIGINT (COUNT_BIG(*))
         FROM ORDERS_HISTORY
  • Example 2: Using the EMPLOYEE table, select the EMPNO column in big integer form for further processing in the application.
       SELECT BIGINT (EMPNO) FROM EMPLOYEE
  • Example 3: Assume that the column RECEIVED (whose data type is TIMESTAMP) has an internal value equivalent to '1988-12-22-14.07.21.136421'.
       BIGINT(RECEIVED)
    results in the value 19 881 222 140 721.
  • Example 4: Assume that the column STARTTIME (whose data type is TIME) has an internal value equivalent to '12:03:04'.
       BIGINT(STARTTIME)
    results in the value 120 304.