Re: MOVE in SQL vs PLPGSQL

From: Richard Huxton <dev(at)archonet(dot)com>
To: andrew(at)pillette(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: MOVE in SQL vs PLPGSQL
Date: 2005-10-05 15:01:15
Message-ID: 4343EABB.6030808@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

andrew(at)pillette(dot)com wrote:
>> Andrew - your question doesn't seem to make sense - can you give
>> some more details? Are you having some problem with cursors in
>> plpgsql?
>
>
> Yes. I'd like the effect of the plain SQL MOVE with a PLPGSQL cursor.
> I'm writing a procedure for which SQL is inadequate (I need
> condiitonal branches and looping). However, in PLPGSQL, it appears
> the only way to fast forward on a cursor is a repeated FETCH, which
> is wasteful. PLPGSQL doesn't even allow me to set up a SQL-type
> cursor using EXECUTE--I have to use the refcursor datatype and it
> doesn't appear to support MOVE.
>
> I could write a procedure client-side in (say) Java without any
> problem using absolute or relative move, but I'd like the procedure
> to run on the server.

Ah, now I see what you're saying. You're quite right in your suspicions,
"MOVE..." isn't supported for plpgsql cursors. You could probably do
something with EXECUTE and returning a refcursor from a previous
function, but that sounds fiddly.

I must admit, on the odd occasion I want to skip a row, I just FETCH it
and move on. Anyone else?

--
Richard Huxton
Archonet Ltd

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Kretschmer 2005-10-05 15:12:26 Re: BirthDay SQL Issue
Previous Message Joost Kraaijeveld 2005-10-05 13:19:40 Re: Help with simple SQL query?