DB2 10.5 for Linux, UNIX, and Windows

NVARCHAR scalar function

The NVARCHAR function returns a varying-length national character string representation of a variety of data types.

Integer to nvarchar

Read syntax diagramSkip visual syntax diagram
>>-NVARCHAR--(--integer-expression--)--------------------------><

Decimal to nvarchar

Read syntax diagramSkip visual syntax diagram
>>-NVARCHAR--(--decimal-expression--+----------------------+--)-><
                                    '-,--decimal-character-'      

Floating-point to nvarchar

Read syntax diagramSkip visual syntax diagram
>>-NVARCHAR--(--floating-point-expression--+----------------------+--)-><
                                           '-,--decimal-character-'      

Decimal floating-point to nvarchar

Read syntax diagramSkip visual syntax diagram
>>-NVARCHAR--(--decimal-floating-point-expression--+----------------------+--)-><
                                                   '-,--decimal-character-'      

Character to nvarchar

Read syntax diagramSkip visual syntax diagram
>>-NVARCHAR--(--character-expression--+------------+--)--------><
                                      '-,--integer-'      

Graphic to nvarchar

Read syntax diagramSkip visual syntax diagram
>>-NVARCHAR--(--graphic-expression--+------------+--)----------><
                                    '-,--integer-'      

Nchar to nvarchar

Read syntax diagramSkip visual syntax diagram
>>-NVARCHAR--(--national-character-expression--+------------+--)-><
                                               '-,--integer-'      

Datetime to nvarchar

Read syntax diagramSkip visual syntax diagram
>>-NVARCHAR--(--datetime-expression--+--------------+--)-------><
                                     '-,--+-ISO---+-'      
                                          +-USA---+        
                                          +-EUR---+        
                                          +-JIS---+        
                                          '-LOCAL-'        

The schema is SYSIBM.

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

NVARCHAR can be specified only in a Unicode database (SQLSTATE 560AA).

The NVARCHAR function returns a varying-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 first 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
  • An 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
The NVARCHAR scalar function is a synonym for a scalar cast function with result string units as specified in the following table.
Table 1. NVARCHAR scalar function synonyms
NVARCHAR_MAPPING value Synonym function Result string units
CHAR_CU32 VARCHAR CODEUNITS32
GRAPHIC_CU32 VARGRAPHIC CODEUNITS32
GRAPHIC_CU16 VARGRAPHIC1 CODEUNITS16
  1. When the first argument has string units CODEUNITS32 and the second argument is not specified, the length attribute of the result is different from the VARGRAPHIC 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 otherwise determined by the VARGRAPHIC function.