Search Postgresql Archives

Having a plpgsql function return multiple rows that indicate its progress in a cursor like fashion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

At the moment my pg client application (running 8.4) transfers data
from several remote DBs (that run 8.3) via dblink, using cursors where
appropriate, and reporting back progress to users using a progress bar
and brief messages.

I thought it would be great to change my code to have all this done
within a single plpgsql function, and have all the benefits that that
brings.

It's easy enough to do all this, by writing a function that RETURNS
TABLE(progress integer, message text), and RETURNing NEXT when time
comes to display a new message or increment the progress bar. However,
that approach has the considerable drawback of not actually returning
any rows until it finally returns all of them. I'm not willing to give
up giving the user those messages and having their progress bar
updated in real-time though. I would like to have the function behave
as a cursor, and return one row at a time when control reaches each
RETURN NEXT statement.

Is it possible to somehow achieve what I've described, perhaps by
doing something with a function that returns refcursor?

Thanks,
Peter Geoghegan

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux