OREPLACE Function Examples | Teradata Vantage - Example 1 - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

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;