# 22. Virtuoso Functions Guide - chr

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
ascii
atoi
blob_to_string
blob_to_string_outpu...
chr
initcap
isblob
isstring
lcase
left
length
locate
ltrim
make_string
regexp_instr
regexp_like
regexp_match
regexp_parse
regexp_replace
regexp_substr
repeat
replace
right
rtrim
search_excerpt
serialize
space
split_and_decode
sprintf
strcasestr
strchr
string_output
string_output_flush
string_output_gz_com...
string_output_string
string_to_file
strrchr
strstr
subseq
substring
tmp_file_name
trim
ucase
upper
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## chr

Convert a long character code to a character or wide character
varchar chr (in chr_codelong);
Parameters
chr_code – The LONG character code value for the character or wide character to be produced.
Return Values

If the chr_code is smaller than or equal to 255, the returned 1 character string will be of type VARCHAR. Otherwise the returned type is NVARCHAR.

Description

chr returns a new one character long string containing the character with character code given as parameter.

Errors

Examples
Simple example

    SQL> select chr (33);
    callret
    VARCHAR
    _______________________________________________________________________________

    !

    1 Rows. -- 3 msec.

Stored procedure example

This stored procedure lists the ASCII values and characters in a string given as argument.

    SQL> create procedure
    test_chr (in str varchar)
    {
      declare pos integer; pos := 0;
      declare c_code, c_code2 integer; declare c_char varchar;

      result_names (c_code, c_code2, c_char);

      while (pos < length (str))
        {
          result (aref (str, pos), ascii (subseq (str, pos, pos+1, 1)),
            chr (aref (str, pos)));
          pos := pos + 1;
        }
    }
    ;

    Done. -- 7 msec.
    SQL> test_chr ('Nebuchadnessar');
    c_code            c_code2           c_char
    INTEGER NOT NULL  INTEGER NOT NULL  VARCHAR NOT NULL
    _______________________________________________________________________________

    78                78                N
    101               101               e
    98                98                b
    117               117               u
    99                99                c
    104               104               h
    97                97                a
    100               100               d
    110               110               n
    101               101               e
    115               115               s
    115               115               s
    97                97                a
    114               114               r

    14 Rows. -- 7 msec.

See Also

aref, ascii