Re: Prepared statements and cursors

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Andreas Lubensky <lubensky(at)cognitec(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Prepared statements and cursors
Date: 2014-01-23 21:07:53
Message-ID: CAHyXU0xa9zbGmtOj+CtLmCf1awDCEF6fk_70Laz2e-uyuqf9hA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 23, 2014 at 8:31 AM, Andreas Lubensky <lubensky(at)cognitec(dot)com> wrote:
> Hello,
> When implementing a database backend with libpq I realized that it seems
> to be impossible to declare a cursor on a prepared statement. Is this
> correct? What is the reason for this limitation?

I can't think of any but it can be trivially worked around:
create or replace function f() returns void as $$ declare v cursor for
select 0; $$ language sql;
prepare p as select f();
postgres=# begin;
BEGIN
postgres=# execute p;
f
---

(1 row)

postgres=# fetch all from v;
?column?
----------
0

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Susan Cassidy 2014-01-23 22:55:46 problem connecting to postgres via apache
Previous Message Susan Cassidy 2014-01-23 17:38:06 Re: Fully-automatic streaming replication failover when master dies?