Subject Re: Query returning row when it shouldn't...
Author phil_sorry_trouble_with_profile
--- In Firebird-Java@yahoogroups.com, "Steffen Heil" <lists@s...> wrote:
> Hi
>
> > java.sql.Statement s = myConnection.createStatement();
> > ResultSet rs = s.executeQuery("select max(PK_SN) from MYTABLE");
> > if (rs.next())
> > // Then the row exists - return the value:
> > return rs.getInt("PK_SN");
>
> > This in itself is not a suprise because there are no rows... the
problem
> is that rs.next() should return false (indicating that there is not
a 'next'
> row).
>
> Wrong. As a lot of others already stated, there is always a result to
> agregate functions. NULL if necessary.
>
> If you consider this a bug, what would you expect from the same query if
> there were rows, but every row had an NULL in PK_SN? [I see, you
ment PK_SN
> to be an primary key (and therefor NOT NULL), but just imagine.]

Well I'm quite accustomed to getting rows and having to check for
isNull... that is quite different from getting a ResultSet with some
data when we are not working with any rows...

>
> Regards,
> Steffen