In SQL Server it's possible to do inline variable assignment.
For example, table dbo.tblSynonym:
+--+-------+-----------+
|id|keyword|replacement|
+--+-------+-----------+
|1 |aaa |bbb |
|2 |xxx |yyy |
|3 |ddd |eee |
+--+-------+-----------+
when I run this:
DECLARE @body varchar(max)='aaa111xxx111ddd'
SELECT @body = REPLACE(@body,keyword,replacement)
FROM dbo.tblSynonym
SELECT @body
The result should be bbb111yyy111eee
.
So the value of @body
will be updated on each row (interaction) and the replace input will be from result of previous rows on the source table.
Is it possible to do something like this in postgres (without cursor)?
Thanks