Skip site navigation (1) Skip section navigation (2)

Concat error in PL/pgsql

From: Hans Peter Wuermli <wurmli(at)freesurf(dot)ch>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Concat error in PL/pgsql
Date: 2001-01-06 17:29:22
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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 the following. 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'
	r record;
	output text;
	output := text('''');
	for r in select * from tconcattest loop
		  output := output || r.str;
	end loop;
	return output;
' 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

Next:From: Tom LaneDate: 2001-01-06 21:38:21
Subject: Re: Concat error in PL/pgsql
Previous:From: Andrew McMillanDate: 2001-01-06 00:00:14
Subject: Re: subselects doesn't work in v7.0.3

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group