Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Replace the string

New RootsFeb 19 2021

Hi All,
Below is my table.

WITH t AS
(SELECT 1as sno,'first|second|thrid|forth|fifth|six' AS str FROM dual
UNION ALL
SELECT 2 AS sno, 'first|secondt|thrid' AS str FROM dual
UNION ALL
SELECT 3 AS sno, 'first' AS str FROM dual
UNION ALL
SELECT 4 AS sno,NULL AS str FROM dual
)
SELECT * FROM t;

---
Replace 'thrid' with '3rd' if the string present.

expected output:

1,'first|second|3rd|forth|fifth|six'
2,'first|second|3rd'
3,'first|3rd'
4,'||3rd'

This post has been answered by New Roots on Feb 19 2021
Jump to Answer
Comments
Post Details
Added on Feb 19 2021
7 comments
497 views