INTTOHEX Function [Data Type Conversion]

Returns the hexadecimal equivalent of a decimal integer.

Syntax

INTTOHEXinteger-expression )

Parameters

Parameters

Parameter

Description

integer-expression

The integer to be converted to hexadecimal.

Returns

VARCHAR

Examples

The following statement returns the value 3B9ACA00:

SELECT INTTOHEX( 1000000000 ) FROM iq_dummy
The following statement returns the value 00000002540BE400:
SELECT INTTOHEX ( 10000000000) FROM iq_dummy

Usage

If data conversion of input to INTTOHEX conversion fails, Sybase IQ returns an error, unless the CONVERSION_ERROR option is OFF. In that case, the result is NULL.

See Reference: Statements and Options > Database Options > Alphabetical List of Options > CONVERSION_ERROR Option [TSQL].

The database option ASE_FUNCTION_BEHAVIOR specifies that output of Sybase IQ functions, including INTTOHEX and HEXTOINT, be consistent with the output of Adaptive Server Enterprise functions. The default value of ASE_FUNCTION_BEHAVIOR is OFF.

See Reference: Statements and Options > Database Options > Alphabetical List of Options > ASE_FUNCTION_BEHAVIOR Option.

When the ASE_FUNCTION_BEHAVIOR option is disabled (the value is OFF):
  • The output of INTTOHEX is compatible with SQL Anywhere.

  • Depending on the input, the output of INTTOHEX can be 8 digits or 16 digits and is left padded with zeros; the return data type is VARCHAR.

  • The output of INTTOHEX does not have a ‘0x’ or ‘0X’ prefix.

  • The input to INTTOHEX can be up to a 64-bit integer.

When the ASE_FUNCTION_BEHAVIOR option is enabled (the value is ON):
  • The output of INTTOHEX is compatible with Adaptive Server Enterprise.

  • The output of INTTOHEX is always 8 digits and is left-padded with zeros; the return data type is VARCHAR.

  • The output of INTTOHEX does not have a ‘0x’ or ‘0X’ prefix.

  • Sybase IQ INTTOHEX assumes input is a 32-bit signed integer; a larger value can overflow and a conversion error can result. For example, the statement:
    SELECT INTTOHEX( 1000000000 ) FROM iq_dummy
    returns the value 3B9ACA00. But the statement:
    SELECT INTTOHEX( 10000000000 ) FROM iq_dummy
    results in a conversion error.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Compatible with Adaptive Server Enterprise.

Related reference
BIGINTTOHEX Function [Data Type Conversion]
HEXTOBIGINT Function [Data Type Conversion]
HEXTOINT Function [Data Type Conversion]