Show TOC

ALPHA(x,n)Locate this document in the navigation structure

Use

ALPHA(x,n) is a string function that enables a character x (string specification) in ASCII to be converted to a different one or two-character representation defined in the DEFAULTMAP ( mapchar_set_name). Only expressions that produce an alphanumeric value are permitted as string specifications x.

ALPHA(x,n) is used to define the sort sequence.

The function ALPHA(x,n) uses the MAPCHAR(x,n,i) function internally (where i is the DEFAULTMAP) and also performs a conversion to uppercase letters via UPPER(y) (where y is MAPCHAR(x,n,i)).

The code on which the character x is based and the code on which the implemented DEFAULTMAP (defined for the ASCII code) is based must match. In Unicode-based database systems string specifications are Unicode. So if necessary convert the string specification to an ASCII expression (using for example the function ASCII(x)).

x, n

Result of the ALPHA(x,n) Function

x is a character

n is an unsigned integer

UPPER(MAPCHAR(x,n,DEFAULTMAP))

Specifying n (an entire number without a sign) is optional. n specifies the maximum length of the result.

Sample Code

The ALPHA function allows a useful sorting process, for example, when "ΓΌ" should be sorted as "UE". The mapchar set with the name DEFAULTMAP is used.

        

SELECT ...,ALPHA(<column_name>) sort, ... FROM ... ORDER BY sort          

        
            
More Information