Pl/Pgsql function troubles - Mailing list pgsql-novice

From Jeff Post
Subject Pl/Pgsql function troubles
Date
Msg-id 1018907628.3cbb4becb9c15@www.panthermail.uwm.edu
Whole thread Raw
List pgsql-novice
I am hoping that I can write a function that will return a comma seperated list
of memberships in a given type ($2) of organiztions for a given userid ($1).
Memberships are available in a view called org_details where all groups list
all there members and types.

I would think that the following should work.  This is the first time that I
have had to use a dynamic query so that could be the source of the problem
(like of understanding) but in the following the function never goes into the
FOR LOOP.

anybody now what I am doing wrong?

maybe a record cannot be returned that points to a view relation?????

all I am trying to do with the raise notice is spit out the Select statment
that the function is using (earlier source of trouble)

CREATE or replace FUNCTION list_of_membership(integer,CHAR) RETURNS TEXT AS '
DECLARE
   membership_rec record;
   membership text := NULL;
   count integer := 0;
BEGIN
   FOR membership_rec IN EXECUTE select name from org_details where person_id =
$1 and type = $2 order by name  LOOP
     RAISE NOTICE ''select name from org_details where person_id = '' || $1
|| '' and type = \''' || $2 || ''\' order by name'' ;
      count := count + 1;
      IF count = 1 THEN
        membership := membership_rec.name;
      ELSE
        membership := membership || '', '' || membership_rec.name;
      END IF;
   END LOOP;
   RETURN membership;
END;
' LANGUAGE 'plpgsql';

Thanks,

Jeff Post

pgsql-novice by date:

Previous
From: "Joshua b. Jore"
Date:
Subject: Re: SQL-Dump and refertial Integrity
Next
From: "Brian Johnson"
Date:
Subject: Adding two select statements together