Re: [GENERAL] Fun with Cursors- how to rewind a cursor

2007-03-01 Thread Postgres User
I had tried several variations of MOVE Backward inside an Execute statement earlier. And now, I'm seeing this error appear again: ERROR: 0A000: cannot manipulate cursors directly in PL/pgSQL I updated the Postgres function below with this replacement line: Execute 'MOVE Backward All In c_entry'

Re: [GENERAL] Fun with Cursors- how to rewind a cursor

2007-03-01 Thread Tom Lane
"Postgres User" <[EMAIL PROTECTED]> writes: > So I added the following code: > ref_entry = 'c_entry'; > MOVE Backward All In c_entry; You have to use EXECUTE for the latter. regards, tom lane ---(end of broadcast)---

Re: [GENERAL] Fun with Cursors- how to rewind a cursor

2007-03-01 Thread Postgres User
Thanks for the pointer. According to the Postgres docs: "The portal name used for a cursor can be specified by the programmer or automatically generated. To specify a portal name, simply assign a string to the refcursor variable before opening it." So I added the following code: ref_entry

Re: [GENERAL] Fun with Cursors- how to rewind a cursor

2007-03-01 Thread Tom Lane
"Postgres User" <[EMAIL PROTECTED]> writes: > Is there any way to 'rewind' the cursor to the first row? plpgsql doesn't have any command for that (though I think someone is working on improving its cursor command set). You should be able to work around it by EXECUTE'ing a MOVE BACKWARD ALL comman

[GENERAL] Fun with Cursors- how to rewind a cursor

2007-03-01 Thread Postgres User
Hi, I'm opening a refcursor in Postgres to return a dataset to the client. However, before returning the cursor, I'd like to iterate thru the rows. Here's the code: DECLARE ref_entry refcursor; rec record; i integer = 0; v_list varchar = ''; BEGIN OPEN ref_entry FOR