Example

Teradata Vantageā„¢ SQL Functions, Expressions, and Predicates

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

The following query returns the string 'TD14.0 is the current version'. The string '13.1' in the source string was replaced by the string '14.0'.

   SELECT OREPLACE('TD13.1 is the current version', '13.1', '14.0'); 

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 'TD13.1 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('TD13.1 is the current version', NULL, '14.0'); 

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;