On Mon, Apr 25, 2005 at 02:40:29PM -0500, Ruff, Jeffry C. SR. wrote:
>
> CREATE FUNCTION userinfo.group_list(text) RETURNS text AS'
> DECLARE
> rec RECORD;
> string text := NULL;
> BEGIN
> FOR rec IN SELECT * FROM userinfo.userdb_groups WHERE username = $1 LOOP
> string := string || rec.groupname || \',\';
The result of "NULL || anything" is NULL. Try initializing "string"
to an empty string instead of NULL.
In 7.4 and later you can use an array constructor and array_to_string():
SELECT array_to_string(array(
SELECT groupname FROM userinfo.userdb_groups WHERE username = 'jruff'
), ',');
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/