Strange stuff with fetch - Mailing list pgsql-general

From Maarten Boekhold
Subject Strange stuff with fetch
Date
Msg-id Pine.SUN.3.91.980617101513.24711B-100000@dutepp0.et.tudelft.nl
Whole thread Raw
List pgsql-general
Hi,

I have a pice of code which does basiccaly this:

$query = "fetch in T";
while (($res = PQexec($PG_CONN, $query)) &&
     ($PGRES_TUPLES_OK == PQresultStatus($res)) &&
     (PQntuples($res) == 1)) {

   do_stuff();
   PQclear($res);
}

As you see I'm still using the old perl-interface :).

Now, this worked splendidly at home. No problems whatsoever. At home I
have 6.3.2. Now I wanted to use the same piece of code in the production
environment (PG_VERSION contains 6.1, but I think it's really 6.2). The
damned thing fails.

But it's not like it doesn't run. It run's, only after fetching 3765
rows, PQresultStatus() returns 0, which is PGRES_EMPTY_QUERY.

If I do the sme things in psql (begin; declare T cursor...; ...; fetch in
T), I have no trouble at all 'walking by' this row.

And the damned thing is that I can't even test for this special case
(PGRES_EMPTY_QUERY) and then continue, cos it's considered an error, and
all queries are ignored till the end of the transaction.

Anybody knows what's going on here?

Maarten

_____________________________________________________________________________
| TU Delft, The Netherlands, Faculty of Information Technology and Systems  |
|                   Department of Electrical Engineering                    |
|           Computer Architecture and Digital Technique section             |
|                          M.Boekhold@et.tudelft.nl                         |
-----------------------------------------------------------------------------


pgsql-general by date:

Previous
From: GABRIEL MORALES CRIBILLERO
Date:
Subject: psql
Next
From: "Jose' Soares Da Silva"
Date:
Subject: Re: [GENERAL] COALESCE() or NVL()