From: | "Ricardo Coelho" <rcoelho(at)px(dot)com(dot)br> |
---|---|
To: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | select MIN/MAX when no row selected |
Date: | 1999-11-17 10:08:51 |
Message-ID: | 002401bf30e3$c1a6b260$03fafdc8@px.com.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 1999-11-17 11:07:45 | Re: [HACKERS] Re: Postgresql Docs.... |
Previous Message | Jan Wieck | 1999-11-17 10:07:48 | regression tests |