String Functions

Function name

Description

ASCII(string_exp)

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

BIT_LENGTH(string_exp)

Returns the length in bits of the string expression.

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 data source-dependent.

CONCAT(string_exp1, string_exp2)

Returns a character string that is the result of concatenating string_exp2 to string_exp1. The resulting string is DBMS-dependent. For example, if the column represents by string_exp1 contained a NULL value, DB2 would return NULL, but SQL Server would return the non-NULL string.

DIFFERENCE(string_exp1, string_exp2)

Returns an integer value that indicates the difference between the values returned by the SOUNDEX function for string_exp1 and string_exp2.

INSERT(string_exp1, start, length, string_exp2)

Returns a character string where length characters have been deleted from string_exp1 beginning at start and where string_exp2 has been inserted into string_exp, beginning at the start.

LCASE(string_exp)

Returns a string equal to that in string_exp with all uppercase characters converted to lowercase.

LEFT(string_exp, count)

Returns the leftmost count characters of string_exp.

LENGTH(string_exp)

Returns the number of characters in string_exp, excluding trailing blanks.

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 the 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 within string_exp2, the value 0 is returned.

LTRIM(string_exp)

Returns the characters of string_exp, with leading blanks removed.

REPEAT(string_exp, count)

Returns a character string composed of string_exp repeated count times.

REPLACE(string_exp1, string_exp2, string_exp3)

Search string_exp1 for occurrences of string_exp2 and replace with string_exp3.

RIGHT(string_exp, count)

Returns the rightmost count characters of string_exp.

RTIM(string_exp)

Returns the characters of string_exp with trailing blanks removed.

SOUNDEX(string_exp)

Returns a data source – dependent character string representing the sound of the words in string_exp. For example, SQL Server returns a 4-digit SOUNDEX code; Oracle returns a phonetic representation of each word.

SPACE(count)

Returns a character string consisting of count spaces.

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.

UCASE(string_exp)

Returns a string equal to that in string_exp with all lowercase characters converted to uppercase