cursor error in libpq program - Mailing list pgsql-general

From Duane Moore III
Subject cursor error in libpq program
Date
Msg-id Pine.SOL.3.95.980607232604.15900A-100000@pecos.ncsa.uiuc.edu
Whole thread Raw
List pgsql-general
OK, I'm baffled.  I have a CGI program that uses libpq/libpq++ to access a
postgres database.  I recently started to use cursors, so I could cut down
on the memory requirements for the front-end.  So, instead of doing
   select * from table;
I implemented a cursor so I could move through the data like so
   declare cursorname cursor for select * from table;

My CGI program allows the user to browse through the rows of the table, so
I have 'previous page', 'next page' links up at the top of the page.  The
only problem is that I can not use the 'MOVE' command to move the cursor
correctly (which defeats the whole point of cursors!)  My program works
fine when I do the following via PgCursor in libpq++.  (The examples are
changed from my actual table names.)

begin
   declare FOO cursor for select * from table;
   fetch forward 20 in FOO;
   close FOO;
end

but when I try to do this:

begin
   declare FOO cursor for select * from table;
   move forward 20 in FOO;
   fetch forward 20 in FOO;
   close FOO;
end

I get the following error after the FETCH command:

   NOTICE:  (transaction aborted): queries ignored until END

The same sequence of commands work when I enter them manually in psql.
Does anyone have a clue why adding the 'move' command should give me this
problem?  Any help would be appreciated.  Please include a reply to my
email address (ddmoore@ncsa.uiuc.edu) because I am not yet subscribed to
this list.

Thanks,
Duane Moore
ddmoore@ncsa.uiuc.edu

PS: Does anyone know if these new lists are being archived on the web like
the old ones?  I found the ftp archive, but it is not nearly as convenient
as the mhonarc archives.


pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [GENERAL] Should I run regression tests?
Next
From: Herouth Maoz
Date:
Subject: Re: [GENERAL] Should I run regression tests?