The following query returns the string '17.10 is the current version'. The string '17.10' in the source string was replaced by the string '17.20'.
SELECT OREPLACE('17.10 is the current version', '17.10', '17.20');
The following query returns the string 'This chair is a brown chair'. Both occurrences of the search string 'bag' in the source string were replaced by the string 'chair'.
SELECT OREPLACE('This bag is a brown bag', 'bag', 'chair');
The following query returns the string '17.10 is the current version'. The source string is returned unchanged since the search string is NULL. The result would be the same if the search string is an empty string or a string that has no matches in the source string.
SELECT OREPLACE('17.10 is the current version', NULL, '17.20');
The following query returns the string 'We removed the extra word'. The occurrence of the search string 'superfluous' was removed from the source string.
SELECT OREPLACE('We removed the superfluous extra word', 'superfluous', NULL);
The result set from the following query will have an ADDRESS column that is the concatenation of the ADDRESS1 and ADDRESS2 columns from the CUSTOMER table, with every occurrence of 'st.' replaced with ' street'.
SELECT OREPLACE(ADDRESS1||ADDRESS2, ' st.', ' street') AS ADDRESS from CUSTOMER;