Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] JDBC next() method

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: "jbarnett(at)pobox(dot)com" <jbarnett(at)pobox(dot)com>, "'pgsql-interfaces(at)hub(dot)org'" <pgsql-interfaces(at)hub(dot)org>
Subject: Re: [INTERFACES] JDBC next() method
Date: 1999-04-19 15:34:52
Message-ID: l03130300b340fc9753f8@[] (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
At 15:57 +0300 on 14/04/1999, Jon Barnett wrote:

> I had expected that an empty result set would be
> returned if the history table is empty (0 rows returned for the select), and
> would be false.  Is this an incorrect interpretation
>on my
> part?

It is. In PostgreSQL, when an aggregate function is used, it always returns
one row containing one field. If it had no values that matched the query,
that one field is NULL.

The result of an aggregate is never 0 rows. It is always one row (per group
if you used GROUP BY).

This is the reason why you have to check for a null field rather than for
the result of next(). You have to call next(), but you don't really have to
check its value, because it will be true once (and once only). You call it
merely to fetch the row. And then you get the value of the field thus
retrieved, and check it for null.


Herouth Maoz, Internet developer.
Open University of Israel - Telem project

In response to

pgsql-interfaces by date

Next:From: Sergio A. KesslerDate: 1999-04-19 17:31:42
Subject: Re: [INTERFACES] Delphi TDataset
Previous:From: Joe DieckertDate: 1999-04-19 05:57:48
Subject: Re: [INTERFACES] Delphi TDataset

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group