Re: using PREPAREd statements in CURSOR

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Björn Lundin <b(dot)f(dot)lundin(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: using PREPAREd statements in CURSOR
Date: 2007-06-28 14:45:55
Message-ID: 4053.1183041955@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?ISO-8859-1?Q?Bj=F6rn_Lundin?= <b(dot)f(dot)lundin(at)gmail(dot)com> writes:
> I'm connecting via libpq and want to
> use prepared statements in a cursor.

You can't.

If you're just interested in fetching a large query result in sections,
there is protocol-level support for doing that without an explicit
cursor, but libpq doesn't expose that feature because it doesn't fit
into its API very well. (I think JDBC does expose it, but that doesn't
help you if you want to code in C...) A well-thought-out API proposal
would probably be favorably received.

If you wanted some other cursor feature like scrollability, the whole
thing is a bit problematic, because the prepared statement's plan was
not made with the intention of using it that way (yes, DECLARE CURSOR
is planned differently than a plain select).

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomasz Rakowski 2007-06-28 15:22:34 Re: autovacumm not working ?
Previous Message Bruce McAlister 2007-06-28 14:41:39 Re: AutoVacuum Behaviour Question