Re: ECPG and Curors. - Mailing list pgsql-general

From John Smith
Subject Re: ECPG and Curors.
Date
Msg-id 00de01c68ec7$690d4030$1400a8c0@rose
Whole thread Raw
In response to Re: ECPG and Curors.  (Michael Meskes <meskes@postgresql.org>)
List pgsql-general
On Mon, Jun 12, 2006 at 11:14:24PM -0400, Peter L. Berghold wrote:
> what I don't see is how to detect that I've fetched the last row from a
> query.   Is there more complete doco on this process somewhere?

You could either handle a NOT FOUND exception, or make use of SQLCODE or
SQLSTATE like this...


EXEC SQL DECLARE csr_fred CURSOR FOR SELECT....

EXEC SQL OPEN csr_fred;

while (SQLCODE == 0) {
    EXEC SQL FETCH csr_fred INTO :jim, :sheila,...

    if (SQLCODE == 0) {

        ....
        body of row processing here
        ....
    }
}

EXEC SQL CLOSE csr_fred;



pgsql-general by date:

Previous
From: "Pat Maddox"
Date:
Subject: Re: Help speeding up this query - maybe need another index?
Next
From: jdwatson1@gmail.com
Date:
Subject: BLOB & Searching