Search code examples
postgresqlplpgsqlcolon-equals

:= sql operator in pgsql function


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?


Solution

  • := 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