Received: from orion.SAPserv.Hamburg.dsh.de (Tpolaris2.sapham.debis.de [53.2.131.8]) by hub.org (8.9.2/8.9.1) with SMTP id MAA07011 for ; Sat, 6 Feb 1999 12:35:22 -0500 (EST) (envelope-from wieck@sapserv.debis.de) Received: by orion.SAPserv.Hamburg.dsh.de for pgsql-sql@postgreSQL.org id m109Bhy-000EBPC; Sat, 6 Feb 99 18:39 MET Message-Id: From: jwieck@debis.com (Jan Wieck) Subject: Re: [SQL] Function returning multiple rows? To: djackson@cpsgroup.com (Jackson, DeJuan) Date: Sat, 6 Feb 1999 18:39:54 +0100 (MET) Cc: kudo@partitur.se, pgsql-sql@postgreSQL.org Reply-To: jwieck@debis.com (Jan Wieck) In-Reply-To: from "Jackson, DeJuan" at Feb 5, 99 11:26:25 am X-Mailer: ELM [version 2.4 PL25] Content-Type: text > > Not currently. Partly right. We cannot return multiple row's (at least the return values aren't useful). But an SQL language function can return multiple results. Only works for SQL language, not C or PL. > > > -----Original Message----- > > From: Patrik Kudo [mailto:kudo@partitur.se] > > Sent: Friday, February 05, 1999 9:54 AM > > To: pgsql-sql@postgreSQL.org > > Subject: [SQL] Function returning multiple rows? > > > > > > Hello, > > > > I've been trying to create a function which returns multiple > > rows, but I > > can't get it working. I'm I doing something wrong, or is it not > > possible? This is my setup: > > > > create table groups (userid int4, grp int4); > > > > CREATE FUNCTION usersingroup(int4) RETURNS int4 AS 'SELECT userid FROM > > groups WHERE grp = $1;' LANGUAGE 'sql'; CREATE FUNCTION usersingroup(int4) RETURNS SETOF int4 AS ' SELECT userid FROM groups WEHRE grp = $1; ' LANGUAGE 'sql'; > > > > > > When doing a > > > > SELECT usersingroup(100); > > > > I only get the first row. Is there any way to get all the rows? With the above you'll get multiple results. The magic word is SETOF. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #======================================== jwieck@debis.com (Jan Wieck) #