From: | jwieck(at)debis(dot)com (Jan Wieck) |
---|---|
To: | djackson(at)cpsgroup(dot)com (Jackson, DeJuan) |
Cc: | kudo(at)partitur(dot)se, pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] Function returning multiple rows? |
Date: | 1999-02-06 17:39:54 |
Message-ID: | m109Bhy-000EBPC@orion.SAPserv.Hamburg.dsh.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
>
> 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(at)partitur(dot)se]
> > Sent: Friday, February 05, 1999 9:54 AM
> > To: pgsql-sql(at)postgreSQL(dot)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(at)debis(dot)com (Jan Wieck) #
From | Date | Subject | |
---|---|---|---|
Next Message | Sascha Schumann | 1999-02-08 00:28:26 | Re: [SQL] Functional Indexes |
Previous Message | Tom Lane | 1999-02-06 17:27:47 | Re: [SQL] Functional Indexes |