Saturday, 7 July 2007

CHR - function

CHR: The CHR function returns the character having the binary equivalent to n as a VARCHAR2 value in either the database character set.

Example: CHR(10)CHR(13) = carriage return plus line feed.

In Oracle/PLSQL, the CHR function is the opposite of the ascii function. It returns the character based on the NUMBER code.

The syntax for the chr function is: CHR( number_code [, USING NCHAR_CS])
where the number_code is the NUMBER code used to retrieve the character.

Use of the CHR function (either with or without the optional USING NCHAR_CS clause) results in code that is not portable between ASCII- and EBCDIC-based machine architectures.

For single-byte character sets, if n > 256, then Oracle returns the binary equivalent of n mod 256. For multibyte character sets, n must resolve to one entire codepoint. Invalid codepoints are not validated, and the result of specifying invalid codepoints is indeterminate.

No comments: