Thread: Is prepared cursored query possible?

Is prepared cursored query possible?

From
"Patric Bechtel"
Date:
Hello folks,

I'm improving the capabilities of the JDBC driver of Postgres at the moment;
only one problem:
I tried to "declare curs_4711 cursor for execute prep_0815;" and get an error
message for the execute inside the statement.
As I refer to the docs, they say only select is possible, which seems illogical
to me. Is that intended or just a parser inability/grammar inability?
Or is there a workaround for that? (maybe a select from ... thingy?)

tia

Patric




Re: Is prepared cursored query possible?

From
Tom Lane
Date:
"Patric Bechtel" <bechtel@ipcon.de> writes:
> As I refer to the docs, they say only select is possible, which seems
> illogical to me.

Why?  A cursor has to have some rows to read, ISTM.  Putting INSERT or
UPDATE or DELETE in it would make no sense.

            regards, tom lane

Re: Is prepared cursored query possible? [Viruschecked]

From
"Patric Bechtel"
Date:
On Wed, 01 Jan 2003 23:22:11 -0500, Tom Lane wrote:

>"Patric Bechtel" <bechtel@ipcon.de> writes:
>> As I refer to the docs, they say only select is possible, which seems
>> illogical to me.
>
>Why?  A cursor has to have some rows to read, ISTM.  Putting INSERT or
>UPDATE or DELETE in it would make no sense.
>
>            regards, tom lane
>
>
That's not the point. I want to prepare a query, like
"prepare myplan(bigint) as select * from adresses where id=$1"
and then
"declare mycurs cursor as execute myplan(47110815)"

That's not possible, as I have to put the source query
behind the cursor declaration.
I WOULD understand when declare failed on prepared
update, delete or insert statements, kind of at least.
But no prepared queries at all?

tia

Patric