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

From Hans Peter Wuermli
Subject Concat error in PL/pgsql
Date
Msg-id 200101061729.SAA31739@obelix.spectraweb.ch
Whole thread Raw
Responses Re: Concat error in PL/pgsql
RE: Concat error in PL/pgsql
List pgsql-bugs
I don't have a bug template at hand.

Within a plpgsql function, concatenating TEXT strings from tables that allow NULL values return nil results. Please run
thefollowing. The result of the second select is nil. 

Cheers, H.P.

-----------------------------------------------------------

create table tconcattest (id char(3),str text);

insert into tconcattest values('hpw',text('Something...'));
insert into tconcattest values('wuh',text('and more of something.'));

create function fconcattest () returns text as'
 declare
    r record;
    output text;
 begin
    output := text('''');
    for r in select * from tconcattest loop
          output := output || r.str;
    end loop;
    return output;
 end;
' language 'plpgsql';

select fconcattest();

insert into tconcattest values('abc',NULL);

select fconcattest();

update tconcattest set str='...again' where id='abc';

select fconcattest();

pgsql-bugs by date:

Previous
From: "bart sikkes"
Date:
Subject: postgresql on vax?
Next
From: Tom Lane
Date:
Subject: Re: Concat error in PL/pgsql