SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-118
REPLACE Function
REPLACE Function
The REPLACE function returns a character string where all occurrences of a specified
character string in the original string are replaced with another character string.
REPLACE is an SQL/MX extension.
char-expr-1, char-expr-2, char-expr-3
are SQL character value expressions. The operands are the result of evaluating
the character expressions. All occurrences of char-expr-2 in char-expr-1
are replaced by char-expr-3. See Character Value Expressions on page 6-37.
Examples of REPLACE
Use the REPLACE function to change job descriptions so that occurrences of the
company name are updated:
SELECT jobdesc FROM persnl.job;
Job Description
------------------
MANAGER COMNET
PRODUCTION COMNET
ASSEMBLER COMNET
SALESREP COMNET
SYSTEM ANAL COMNET
...
--- 10 row(s) selected.
UPDATE persnl.job
SET jobdesc = REPLACE (jobdesc, 'COMNET', 'TDMNET');
Job Description
------------------
MANAGER TDMNET
PRODUCTION TDMNET
ASSEMBLER TDMNET
SALESREP TDMNET
SYSTEM ANAL TDMNET
...
--- 10 row(s) selected.
REPLACE (char-expr-1, char-expr-2, char-expr-3)