Reputation: 2463
I want to do string replace in some data in pgsql
database column. I tried
CASE
WHEN (po.siteid IS NOT NULL) THEN replace('po.html_content', 'abcd', 'xxx')
ELSE pc.html_content
END
I want to replace string in po.html_content
column. But above code is not working. Query get the data in po.html_content
column without replacing.
Is my code is wrong or any idea...
Upvotes: 3
Views: 23805
Reputation: 263933
Don't enclosed the column name in a single quote, in that case, it is not a column anymore but a regular string.
CASE
WHEN (po.siteid IS NOT NULL) THEN replace(po.html_content, 'abcd', 'xxx')
ELSE pc.html_content
END
Upvotes: 5