pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedfunction returning multiple rows?
4+ messages / 3 participants
[nested] [flat]
* function returning multiple rows?
@ 1999-02-05 15:48 Patrik Kudo <kudo@partitur.se>
0 siblings, 0 replies; 4+ messages in thread
From: Patrik Kudo @ 1999-02-05 15:48 UTC (permalink / raw)
To: pgsql-sql
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';
When doing a
SELECT usersingroup(100);
I only get the first row. Is there any way to get all the rows?
Regards,
Patrik Kudo
kudo@partitur.se
^ permalink raw reply [nested|flat] 4+ messages in thread
* Function returning multiple rows?
@ 1999-02-05 15:54 Patrik Kudo <kudo@partitur.se>
0 siblings, 0 replies; 4+ messages in thread
From: Patrik Kudo @ 1999-02-05 15:54 UTC (permalink / raw)
To: pgsql-sql
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';
When doing a
SELECT usersingroup(100);
I only get the first row. Is there any way to get all the rows?
Regards,
Patrik Kudo
kudo@partitur.se
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: [SQL] Function returning multiple rows?
@ 1999-02-05 17:26 Jackson, DeJuan <djackson@cpsgroup.com>
1999-02-06 17:39 ` Re: [SQL] Function returning multiple rows? Jan Wieck <jwieck@debis.com>
0 siblings, 1 reply; 4+ messages in thread
From: Jackson, DeJuan @ 1999-02-05 17:26 UTC (permalink / raw)
To: Patrik Kudo <kudo@partitur.se>; pgsql-sql
Not currently.
> -----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';
>
>
> When doing a
>
> SELECT usersingroup(100);
>
> I only get the first row. Is there any way to get all the rows?
>
> Regards,
> Patrik Kudo
> kudo@partitur.se
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Function returning multiple rows?
1999-02-05 17:26 RE: [SQL] Function returning multiple rows? Jackson, DeJuan <djackson@cpsgroup.com>
@ 1999-02-06 17:39 ` Jan Wieck <jwieck@debis.com>
0 siblings, 0 replies; 4+ messages in thread
From: jwieck@debis.com @ 1999-02-06 17:39 UTC (permalink / raw)
To: djackson@cpsgroup.com; +Cc: kudo@partitur.se; 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@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) #
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1999-02-06 17:39 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-02-05 15:48 function returning multiple rows? Patrik Kudo <kudo@partitur.se>
1999-02-05 15:54 Function returning multiple rows? Patrik Kudo <kudo@partitur.se>
1999-02-05 17:26 RE: [SQL] Function returning multiple rows? Jackson, DeJuan <djackson@cpsgroup.com>
1999-02-06 17:39 ` Re: [SQL] Function returning multiple rows? Jan Wieck <jwieck@debis.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox