TRANSLATE
Syntax
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> TRANSLATE[TRANSLATE]:::quoted
TRANSLATE --> End((END))
Purpose
The TRANSLATE SQL function replaces all occurrences of each character in from_string to its corresponding character in to_string.
See also REPLACE.
Parameters:
input(varchar2): The text to replace a sequence of characters with another set of characters.from_string(varchar2): The text that will be searched for in the input.to_string(varchar2): All characters in thefrom_stringwill be replaced with the corresponding character in theto_string.
Returns: the input with all occurrences of each character in from_string replaced by its corresponding character in to_string.
Examples
The following example replaces the characters *, , / and - each by _, and removes the character ' since it has no corresponding character in to_string:
select translate('some*text to/be testing-wit''h', '* /-''', '____')
----------------------------
some_text_to_be_testing_with
The following example returns the input unchanged since none of the characters in from_string occur in the input:
select translate('some*text to/be testing-wit''h', '_____', '_____')
-----------------------------
some*text to/be testing-wit'h