Re: ECPG and Curors.

From: "John Smith" <john(at)roundel(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Cc: <Peter(at)berghold(dot)net>
Subject: Re: ECPG and Curors.
Date: 2006-06-13 08:57:32
Message-ID: 00de01c68ec7$690d4030$1400a8c0@rose
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Florian G. Pflug 2006-06-13 12:17:19 Re: Searching BLOB
Previous Message Fernando Sánchez Cervera 2006-06-13 08:45:49 Error: Server doesn't listen