translate
Translates a character string.
Available in:
Apps (win) |
Apps (char) |
Reportwriter |
RPC |
Standalone PL |
X |
X |
X |
X |
X |
Syntax
string translate(data,from,to)
string data,from,to
Description
Replaces all characters in data as specified.
If the number of characters in to is a multiple of the number
of characters in from, for each character in from,
that multiple of characters from to replaces that
single character.
If to is empty, all characters found in from are deleted.
data | specifies the string to translate.
|
from | specifies the characters to replace.
|
to | specifies new characters to use.
|
Example
Replace all digits with asterisk (*).
field = translate(SAL,"0123456789","**********");
Replace all nulls with a record separator. Multi-line Oracle error messages are dlimited by NULL. Some TRIMpl functions, e.g. tokenize, do not accept NULL as a separator.
buf = translate(db_msg(),chr(0),chr(30));
Replace all single quotes with two single quotes (useful for SQL INSERT
commands).
exec_sql(translate(sqlstmt,"'","''"));
Delete all commas from character representation of numerics.
buf = translate(line,",","");
Validate that a string contains only uppercase letters.
if (translate(line,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","") != "")
error("Line may only contain letters");