pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: andrew@pillette.com
Cc: pgsql-sql@postgresql.org
Subject: Re: MOVE in SQL vs PLPGSQL
Date: Wed, 05 Oct 2005 16:01:15 +0100
Message-ID: <4343EABB.6030808@archonet.com> (raw)
In-Reply-To: <200510051417.j95EH0518161@pillette.com>
References: <200510051417.j95EH0518161@pillette.com>

andrew@pillette.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



view thread (5+ messages)  latest in thread

Message-ID: <4343EABB.6030808@archonet.com>
Permalink:  ../4343EABB.6030808@archonet.com/
Also on:    postgresql.org/message-id/4343EABB.6030808@archonet.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: dev@archonet.com, andrew@pillette.com
  Subject: Re: MOVE in SQL vs PLPGSQL
  In-Reply-To: <4343EABB.6030808@archonet.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