pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: jbarnett@pobox.com <jbarnett@pobox.com>
To: 'pgsql-interfaces@hub.org' <pgsql-interfaces@hub.org>
Subject: Re: [INTERFACES] JDBC next() method
Date: Mon, 19 Apr 1999 18:34:52 +0300
Message-ID: <l03130300b340fc9753f8@[147.233.159.109]> (raw)
In-Reply-To: <01BE86CA.23683420.jbarnett@pobox.com>

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
> queryResult.next() 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

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (13+ messages)  latest in thread

Message-ID: <l03130300b340fc9753f8@[147.233.159.109]>
Permalink:  ../l03130300b340fc9753f8@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130300b340fc9753f8@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-interfaces@postgresql.org
  Cc: herouth@oumail.openu.ac.il, jbarnett@pobox.com, pgsql-interfaces@hub.org
  Subject: Re: [INTERFACES] JDBC next() method
  In-Reply-To: <l03130300b340fc9753f8@[147.233.159.109]>
  References: <01BE86CA.23683420.jbarnett@pobox.com> <l03130300b340fc9753f8@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox