CONVERT Function

Replaces individual characters within a string.

Syntax

CONVERT(oldString, oldCharList, newCharList)

Syntax Elements

oldString The original string.

oldCharList The list of characters to be changed.

newCharList A list of replacement characters.

Operation

The CONVERT function replaces every occurrence of each character in oldCharList that appears in oldString with the corresponding character listed in newCharList. This function treats oldCharList and newCharList as a list of characters rather than as a string of characters. For example, the first character in oldCharList is replaced by the first character in newCharList; the second character in oldCharList is replaced by the second character in newCharList, and so on.

Case Insensitivity

If data case insensitive mode is selected (see Case Sensitivity), case is ignored when searching oldString for the characters in oldCharList.

See Also

CONVERT statement, CHANGE function.

Examples

OLDSTR = "HOLLYWOOD, CA 93062"
A = "CA96"
B = "FL32"
NEWSTR = CONVERT(OLDSTR,A,B)

Replaces each occurrence of C, A, 9 and 6 in OLDSTR with F, L, 3 and 2, respectively. The resulting string (HOLLYWOOD, FL 33022) is placed in NEWSTR.

X = "ABC123DEF456DKDKEIS"
Y = "C2DK"
Z = "Z9:"
A2 = CONVERT(X,Y,Z)

Changes the value of ABC123DEF456DKDKEIS to ABZ193:EF456::EIS and places this new value in A2. Note that K is missing from A2 because K did not have a replacement character in Z.