Unix Technical Forum

Returning multiple cursors from PL/PgSQL

This is a discussion on Returning multiple cursors from PL/PgSQL within the Pgsql Patches forums, part of the PostgreSQL category; --> Folks, Please find attached an example that allows people to return multiple named refcursors from a function. Big kudos ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 10:57 PM
David Fetter
 
Posts: n/a
Default Returning multiple cursors from PL/PgSQL

Folks,

Please find attached an example that allows people to return multiple
named refcursors from a function. Big kudos to Kris Jurka for
figuring this out and pasting to rafb

Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 10:57 PM
David Fetter
 
Posts: n/a
Default Re: Returning multiple cursors from PL/PgSQL

On Wed, Jan 12, 2005 at 09:33:30PM -0800, David Fetter wrote:
> Folks,
>
> Please find attached an example that allows people to return multiple
> named refcursors from a function. Big kudos to Kris Jurka for
> figuring this out and pasting to rafb


Oops. Joe Conway pointed out that this patch could be more succinct
and not create an essentially useless new type.

Please find attached the revised patch.

Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 10:57 PM
Tom Lane
 
Posts: n/a
Default Re: Returning multiple cursors from PL/PgSQL

David Fetter <david@fetter.org> writes:
>> Please find attached an example that allows people to return multiple
>> named refcursors from a function. Big kudos to Kris Jurka for
>> figuring this out and pasting to rafb


> Oops. Joe Conway pointed out that this patch could be more succinct
> and not create an essentially useless new type.


I think the example is pretty confusing, or at least not compelling,
since it's not clear to the reader why you'd go to all that trouble
to return two scalars. The cursors ought to return rowsets.
Maybe

+ OPEN $1 FOR SELECT * FROM table1;
+ RETURN NEXT $1;
+ OPEN $2 FOR SELECT * FROM table2;
+ RETURN NEXT $2;

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 10:57 PM
David Fetter
 
Posts: n/a
Default Re: Returning multiple cursors from PL/PgSQL

On Thu, Jan 13, 2005 at 01:44:58PM -0500, Tom Lane wrote:
> David Fetter <david@fetter.org> writes:
> >> Please find attached an example that allows people to return multiple
> >> named refcursors from a function. Big kudos to Kris Jurka for
> >> figuring this out and pasting to rafb

>
> > Oops. Joe Conway pointed out that this patch could be more succinct
> > and not create an essentially useless new type.

>
> I think the example is pretty confusing, or at least not compelling,
> since it's not clear to the reader why you'd go to all that trouble
> to return two scalars. The cursors ought to return rowsets.
> Maybe
>
> + OPEN $1 FOR SELECT * FROM table1;
> + RETURN NEXT $1;
> + OPEN $2 FOR SELECT * FROM table2;
> + RETURN NEXT $2;
>
> regards, tom lane


Good point. Next patch attached

Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 10:57 PM
Tom Lane
 
Posts: n/a
Default Re: Returning multiple cursors from PL/PgSQL

David Fetter <david@fetter.org> writes:
> Please find attached an example that allows people to return multiple
> named refcursors from a function. Big kudos to Kris Jurka for
> figuring this out and pasting to rafb


Applied the latest version of this.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:15 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com