replace function

The replace function returns the source with every occurrence of the search string replaced with the replacement string.

returnvalue replace(source, search_string [, replacement_string])

source ::= any*
search_string ::= any*
replacement_string ::= any*
returnvalue ::= string

Example 1 - Replace the source location of the passenger with ticket number **1762320569757 from SFO to SOF.**

SELECT replace(bag.bagInfo[0].routing,"SFO","SOF")
FROM baggageInfo bag
WHERE ticketNo=1762320569757

Output:

{"Column_1":"SOF/IST/ATH/JTR"}

Example 2 - Replace the double quote in the passenger name with a single quote.

If your data might contain a double quote in the passenger’s name, you can use replace function to change the double quote to a single quote.

SELECT fullname,
replace(fullname, """, "'") as new_fullname
FROM BaggageInfo bag