NCHAR scalar function

The NCHAR function returns a fixed-length national character string representation of a variety of data types.

Integer to nchar

Read syntax diagramSkip visual syntax diagramNCHAR(integer-expression )

Decimal to nchar

Read syntax diagramSkip visual syntax diagramNCHAR(decimal-expression ,decimal-character )

Floating-point to nchar

Read syntax diagramSkip visual syntax diagram NCHAR(floating-point-expression ,decimal-character )

Decimal floating-point to nchar

Read syntax diagramSkip visual syntax diagramNCHAR(decimal-floating-point-expression ,decimal-character )

Character to nchar

Read syntax diagramSkip visual syntax diagramNCHAR(character-expression ,integer)

Graphic to nchar

Read syntax diagramSkip visual syntax diagramNCHAR(graphic-expression ,integer)

Nchar to nchar

Read syntax diagramSkip visual syntax diagramNCHAR(national-character-expression ,integer )

Datetime to nchar

Read syntax diagramSkip visual syntax diagramNCHAR(datetime-expression ,ISOUSAEURJISLOCAL)

Boolean to nvarchar

Read syntax diagramSkip visual syntax diagram NVARCHAR ( boolean-expression )

The schema is SYSIBM. The function name cannot be specified as a qualified name when keywords are used in the function signature.

The NCHAR function can be specified only in a Unicode database (SQLSTATE 560AA).

Result

The NCHAR function returns a fixed-length national character string representation of:
  • An integer number, if the first argument is a SMALLINT, INTEGER, or BIGINT
  • A decimal number, if the first argument is a decimal number
  • A double-precision floating-point number, if the first argument is a DOUBLE or REAL
  • A decimal floating-point number, if the argument is a decimal floating-point number (DECFLOAT)
  • A character string, if the first argument is any type of character string
  • A graphic string, if the first argument is any type of graphic string
  • A national character string, if the first argument is any type of national character string
  • A datetime value, if the first argument is a DATE, TIME, or TIMESTAMP
  • A Boolean value (TRUE or FALSE)
The NCHAR scalar function is a synonym for a scalar cast function with result string units as specified in the following table.
Table 1. NCHAR scalar function synonyms
NCHAR_MAPPING value Synonym function Result string units
CHAR_CU32 CHAR CODEUNITS32
GRAPHIC_CU32 GRAPHIC CODEUNITS32
GRAPHIC_CU16 GRAPHIC1 CODEUNITS16
  1. When the first argument has string units of CODEUNITS32 and the second argument is not specified, the length attribute of the result is different from the GRAPHIC function because the string units of the result is CODEUNITS16. In this case, the length attribute of the result is 2 times the length attribute of the result that is determined by the GRAPHIC function.