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
Concatenation is the process of appending one string to the end of another string. You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.
In PostgreSQL, the select into statement to select data from the database and assign it to a variable. Syntax: select select_list into variable_name from table_expression; In this syntax, one can place the variable after the into keyword.
The PostgreSQL concatenate operator ( || ) is used to concatenate two or more strings and non strings.
AFAIK, SET statement in PostgreSQL used for changing configutation parameters, for variable assignment just use :=
:
val := '(' || someval || ')';
sql fiddle demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With