Re: Concat error in PL/pgsql - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Concat error in PL/pgsql
Date
Msg-id 18636.978817101@sss.pgh.pa.us
Whole thread Raw
In response to Concat error in PL/pgsql  (Hans Peter Wuermli <wurmli@freesurf.ch>)
List pgsql-bugs
Hans Peter Wuermli <wurmli@freesurf.ch> writes:
> Within a plpgsql function, concatenating TEXT strings from tables that
> allow NULL values return nil results.

That's not a bug: NULL concatenated with anything produces NULL,
per SQL92 specification.

If you want a NULL to act like an empty string, try

    for r in select * from tconcattest loop
          output := output || coalesce(r.str, '''');

            regards, tom lane

pgsql-bugs by date:

Previous
From: Hans Peter Wuermli
Date:
Subject: Concat error in PL/pgsql
Next
From: "Robert B. Easter"
Date:
Subject: boolean bugs