Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

CHAR (SQL)

A string function that returns the character that has the ASCII code value specified in a string expression.

Synopsis

CHAR(code-value)
{fn CHAR(code-value)}

Arguments

Argument Description
code-value An integer code that corresponds to a character.

Description

CHAR returns the character that corresponds to the specified integer code value. On Unicode systems, you can specify the integer code for any Unicode character, 0 through 65535. CHAR returns NULL if code-value is a integer that exceeds the permissible range of values.

CHAR returns an empty string ('') if code-value is a nonnumeric string. CHAR returns NULL if passed a NULL value.

Note that CHAR can be used as an ODBC scalar function (with the curly brace syntax) or as an SQL general function.

Examples

The following examples both return the character Z:

SELECT CHAR(90) AS CharCode
SELECT {fn CHAR(90)} AS CharCode

The following example returns the Greek letter lambda:

  IF $SYSTEM.Version.IsUnicode() {
  &sql(SELECT {fn CHAR(955)}
       INTO :greeklet)
  WRITE !,"Greek letter: ",greeklet
  }
  ELSE {WRITE "This example requires a Unicode installation of Caché"}

Note that the above example requires a Unicode installation of Caché.

See Also

Feedback