pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Dawid Kuroczko <qnex42@gmail.com>
Cc: Postgres General <pgsql-general@postgresql.org>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Scrolling cursors in PL/PgSQL
Date: Thu, 1 Nov 2007 22:05:38 +0100
Message-ID: <162867790711011405x22b205afj9b89645e4f6a2174@mail.gmail.com> (raw)
In-Reply-To: <758d5e7f0711011319t5e752dsad6481d1427a46ff@mail.gmail.com>
References: <758d5e7f0711011319t5e752dsad6481d1427a46ff@mail.gmail.com>

On 01/11/2007, Dawid Kuroczko <qnex42@gmail.com> wrote:
> Hello.
>
> Is there a way to scroll a cursor from within PL/PgSQL?
>
> I tried EXECUTE, but:
>
> ERROR:  cannot manipulate cursors directly in PL/pgSQL
> HINT:  Use PL/pgSQL's cursor features instead.
>
> The idea would be that PL/pgsql function would look
> through (all) query results, then rewind the cursor and
> finally return it.
>
> My fellow developers have created a function which run
> the (complex) query twice (first a count(*) on the result
> set, then return the row count and cursor to the results.
> Then they created a version which uses temporary
> table as a placeholder for the query results, and results
> count and a pointer to select * from tmp_table.
>
> Now I imagined a function which would open the cursor,
> MOVE FORWARD ALL, then MOVE ABSOLUTE 0;
> and return count and a cursor, yet it seems it won't work.
>
> Any other idea how to efficiently solve such a problem?
>

Hello

PostgreSQL 8.3 allows scrollable cursors in plpgsql

Regards
Pavel Stehule



view thread (4+ messages)  latest in thread

Message-ID: <162867790711011405x22b205afj9b89645e4f6a2174@mail.gmail.com>
Permalink:  ../162867790711011405x22b205afj9b89645e4f6a2174@mail.gmail.com/
Also on:    postgresql.org/message-id/162867790711011405x22b205afj9b89645e4f6a2174@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pavel.stehule@gmail.com, qnex42@gmail.com, pgsql-general@postgresql.org
  Subject: Re: Scrolling cursors in PL/PgSQL
  In-Reply-To: <162867790711011405x22b205afj9b89645e4f6a2174@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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