Skip to content
Advertisement

Concatenate string in statement that assigns a variable in PostgreSQL

I am trying to convert SQL Server procedure to PostgreSQL.

In the SQL Server procedure There are statements like below

SET @val = ‘(‘ + @someval + ‘)’

So in postgresql I wrote as below

SET val = ‘(‘ || someval || ‘)’;

But the above statement giving error at ||

Any body can please tell me where am I making mistake

Advertisement

Answer

AFAIK, SET statement in PostgreSQL used for changing configutation parameters, for variable assignment just use :=:

val := '(' || someval || ')';

sql fiddle demo

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement