Call Level Interface Guide and Reference

String Functions

The string functions in this section are supported by DB2 CLI and defined by ODBC using vendor escape clauses.


Table 189. String Scalar Functions

ASCII( string_exp )
Returns the ASCII code value of the leftmost character of string_exp as an integer.

DB2 for common server 2.1      

CHAR( code )
Returns the character that has the ASCII code value specified by code. The value of code should be between 0 and 255; otherwise, the return value is null.

DB2 for common server 2.1      

CONCAT( string_exp1, string_exp2 )
Returns a character string that is the result of concatenating string_exp2 to string_exp1.

DB2 for common server 1.1 MVS VM/VSE AS/400

DIFFERENCE( string_exp1, string_exp2 )
Returns an integer value indicating the difference between the values returned by the SOUNDEX function for string_exp1 and string_exp2.

DB2 for common server 1.1


INSERT( string_exp1, start, length, string_exp2 )
Returns a character string where length number of characters beginning at start has been replaced by string_exp2 which contains length characters.

DB2 for common server 1.1 MVS VM/VSE AS/400

LCASE( string_exp )
Converts all upper case characters in string_exp to lower case.

DB2 for common server 1.0   VM/VSE  

LEFT( string_exp,count )
Returns the leftmost count of characters of string_exp.

DB2 for common server 1.0 MVS VM/VSE AS/400

LENGTH( string_exp )
Returns the number of characters in string_exp, excluding trailing blanks and the string termination character.
Note:Trailing blanks were included prior to Version 2.1. Trailing blanks are still included for DB2 for MVS/ESA.
DB2 for common server 1.0 MVS VM/VSE AS/400

LOCATE( string_exp1, string_exp2 [ ,start ])
Returns the starting position of the first occurrence of string_exp1 within string_exp2. The search for the first occurrence of string_exp1 begins with first character position in string_exp2 unless the optional argument, start, is specified. If start is specified, the search begins with the character position indicated by the value of start. The first character position in string_exp2 is indicated by the value 1. If string_exp1 is not found withing string_exp2, the value 0 is returned.

DB2 for common server 2.1      

LTRIM( string_exp )
Returns the characters of string_exp with the leading blanks removed.

DB2 for common server 2.1 VM/VSE   AS/400

REPEAT( string_exp, count )
Returns a character string composed of string_exp repeated count times.

DB2 for common server 2.1 MVS VM/VSE AS/400

REPLACE( string_exp1, string_exp2, string_exp3 )
Replaces all occurrences of string_exp2 in string_exp1 with string_exp3.

DB2 for common server 2.1      

RIGHT( string_exp, count )
Returns the rightmost count of characters of string_exp.

DB2 for common server 1.0 MVS VM/VSE AS/400

RTRIM( string_exp )
Returns the characters of string_exp with trailing blanks removed.

DB2 for common server 2.1   VM/VSE AS/400

SOUNDEX( string_exp1 )
Returns a four character code representing the sound of string_exp1. Note that different data sources use different algorithms to represent the sound of string_exp1.

DB2 for common server 1.1


SPACE( count )
Returns a character string consisting of count spaces.

DB2 for common server 2.1      

SUBSTRING( string_exp, start, length )
Returns a character string that is derived from string_exp beginning at the character position specified by start for length characters.

DB2 for common server 1.0 MVS VM/VSE AS/400

UCASE( string_exp )
Converts all lower case characters in string_exp to upper case.

DB2 for common server 1.0   VM/VSE AS/400


[ Top of Page | Previous Page | Next Page ]