PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References
PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References

PostgreSQL CHR() Function



The PostgreSQL CHR() function returns character with the given code. For UTF8, this function treats the argument as a Unicode code point. For other multibyte encodings the argument must designate an ASCII character.

Syntax

CHR(number)

Parameters

number Required. Specify integer whose character values is to be retrieved.

Return Value

Returns character with the given code.

Example 1:

The example below shows the usage of CHR() function.

SELECT CHR(72);
Result: 'H'

SELECT CHR(NULL);
Result: NULL

SELECT CHR('72');
Result: 'H'

Example 2:

Consider a database table called Sample with the following records:

DataNumbers
Data167
Data264
Data384
Data466
Data535
Data6100

The statement given below can be used to get the character given by the code values specified by column Numbers.

SELECT *, CHR(Numbers) AS CHR_Value FROM Sample;

The query will produce the following result:

DataNumbersCHR_Value
Data167C
Data264@
Data384T
Data466B
Data535#
Data6100d

❮ PostgreSQL Functions