select MIN/MAX when no row selected - Mailing list pgsql-hackers

From Ricardo Coelho
Subject select MIN/MAX when no row selected
Date
Msg-id 002401bf30e3$c1a6b260$03fafdc8@px.com.br
Whole thread Raw
List pgsql-hackers
Hi All,

I think I had read this question with count(*) before.....

PgSql returns one row with a null field when we use select MIN or MAX on a
table, but the result should be "no rows selected".

I didn't try with C function, but I got the same result with psql.

So, I'm sending a Java example to Peter.

try {   rs=stmt.executeQuery("select min(field1) from tab where
field1>maxValueOfField1");   if (rs.next()) {       System.out.println("I found a row !!!!");
theResult=rs.getString(1);      if (theResult==null)           System.out.println("Min of field1 is NULL !!!!");   }
 
} catch (.............

maxValueofField1 = select max(field1) from tab;

Is it correct ?

I'm using PgSql 6.5.2, RHLinux/Intel 6.0

Thanks,

Ricardo Coelho.





pgsql-hackers by date:

Previous
From: wieck@debis.com (Jan Wieck)
Date:
Subject: regression tests
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] Re: Postgresql Docs....