5

I came across this operator := in a postgresql function:

searchsql:= searchsql || ' WHERE 1=1 ' ;

I googled but cannot find the answer, what does it mean?

moodymudskipper
  • 42,696
  • 10
  • 102
  • 146
dtjmsy
  • 2,516
  • 9
  • 39
  • 58

1 Answers1

5

:= is the assignment operator in PL/pgSQL

The expression

searchsql:= searchsql || ' WHERE 1=1 ' ;

appends the string ' WHERE 1=1 ' to the current value of the variable searchsql

See the manual for details:
http://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-ASSIGNMENT

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843