pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow do i return a dataset from a stored procedure
4+ messages / 4 participants
[nested] [flat]
* How do i return a dataset from a stored procedure
@ 2002-07-05 08:32 teknokrat <teknokrat@yahoo.com>
2002-07-05 16:10 ` Re: How do i return a dataset from a stored procedure Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-07-05 16:21 ` Re: How do i return a dataset from a stored procedure Roberto Mello <rmello@cc.usu.edu>
0 siblings, 2 replies; 4+ messages in thread
From: teknokrat@yahoo.com @ 2002-07-05 08:32 UTC (permalink / raw)
To: pgsql-sql
I can't figure out how to return a group of rows from a function
written in plpgsql (or plsql for that matter). The only way i have
seen it done is with a setof table return value in sql. But since the
query was a single select anyway i don't see the point of this. Is
there a way of creating a temporary table in a procedure and using it
as the output?
thanks
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How do i return a dataset from a stored procedure
2002-07-05 08:32 How do i return a dataset from a stored procedure teknokrat <teknokrat@yahoo.com>
@ 2002-07-05 16:10 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
1 sibling, 0 replies; 4+ messages in thread
From: Stephan Szabo @ 2002-07-05 16:10 UTC (permalink / raw)
To: teknokrat <teknokrat@yahoo.com>; +Cc: pgsql-sql
On 5 Jul 2002, teknokrat wrote:
> I can't figure out how to return a group of rows from a function
> written in plpgsql (or plsql for that matter). The only way i have
> seen it done is with a setof table return value in sql. But since the
> query was a single select anyway i don't see the point of this. Is
> there a way of creating a temporary table in a procedure and using it
> as the output?
In 7.2 you can return open cursors from plpgsql functions. You can
make temp tables in a function, but you have to be careful to make sure
that you don't conflict (what happens if the user calls your function
twice)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How do i return a dataset from a stored procedure
2002-07-05 08:32 How do i return a dataset from a stored procedure teknokrat <teknokrat@yahoo.com>
@ 2002-07-05 16:21 ` Roberto Mello <rmello@cc.usu.edu>
2002-07-06 02:17 ` Re: How do i return a dataset from a stored procedure Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 1 reply; 4+ messages in thread
From: Roberto Mello @ 2002-07-05 16:21 UTC (permalink / raw)
To: teknokrat <teknokrat@yahoo.com>; +Cc: pgsql-sql
On Fri, Jul 05, 2002 at 01:32:33AM -0700, teknokrat wrote:
> I can't figure out how to return a group of rows from a function
> written in plpgsql (or plsql for that matter). The only way i have
> seen it done is with a setof table return value in sql. But since the
> query was a single select anyway i don't see the point of this. Is
> there a way of creating a temporary table in a procedure and using it
> as the output?
Search the list archives (through groups.google.com - it's
comp.databases.postgresql) or see the developer docs for PL/pgSQL. You
can achive that effect by returning a cursor in PG 7.2 (the section on
returning cursors is ommitted from the current docs in
www.postgresql.org/idocs, so you need to look at the developer docs - see
www.us.postgresql.org).
-Roberto
--
+----| http://fslc.usu.edu/ USU Free Software & GNU/Linux Club |------+
Roberto Mello - Computer Science, USU - http://www.brasileiro.net/
http://www.sdl.usu.edu/ - Space Dynamics Lab, Developer
Go straight to the docs. Do not pass GO. Do not collect $200!
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How do i return a dataset from a stored procedure
2002-07-05 08:32 How do i return a dataset from a stored procedure teknokrat <teknokrat@yahoo.com>
2002-07-05 16:21 ` Re: How do i return a dataset from a stored procedure Roberto Mello <rmello@cc.usu.edu>
@ 2002-07-06 02:17 ` Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Bruce Momjian @ 2002-07-06 02:17 UTC (permalink / raw)
To: Roberto Mello <rmello@cc.usu.edu>; +Cc: teknokrat <teknokrat@yahoo.com>; pgsql-sql
Roberto Mello wrote:
> On Fri, Jul 05, 2002 at 01:32:33AM -0700, teknokrat wrote:
> > I can't figure out how to return a group of rows from a function
> > written in plpgsql (or plsql for that matter). The only way i have
> > seen it done is with a setof table return value in sql. But since the
> > query was a single select anyway i don't see the point of this. Is
> > there a way of creating a temporary table in a procedure and using it
> > as the output?
>
> Search the list archives (through groups.google.com - it's
> comp.databases.postgresql) or see the developer docs for PL/pgSQL. You
> can achive that effect by returning a cursor in PG 7.2 (the section on
> returning cursors is ommitted from the current docs in
> www.postgresql.org/idocs, so you need to look at the developer docs - see
> www.us.postgresql.org).
7.3 will have better docs on using it but you can see them now in the
developers docs:
http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html
See the bottom of that page for examples.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-07-06 02:17 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-05 08:32 How do i return a dataset from a stored procedure teknokrat <teknokrat@yahoo.com>
2002-07-05 16:10 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-07-05 16:21 ` Roberto Mello <rmello@cc.usu.edu>
2002-07-06 02:17 ` Bruce Momjian <pgman@candle.pha.pa.us>
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