Subject | Re: [Firebird-Java] Query returning row when it shouldn't... |
---|---|
Author | Stefan Mühlemann |
Post date | 2004-05-31T05:03:53Z |
Phil wrote:
Try
ResultSet rs = s.executeQuery("select max(PK_SN) maxPKSN from MYTABLE");
if (rs.next())
// Then the row exists - return the value:
return rs.getInt("maxPKSN");
or
ResultSet rs = s.executeQuery("select max(PK_SN) maxPKSN from MYTABLE");
if (rs.next())
// Then the row exists - return the value:
return rs.getInt(1);
Stefan
> Hi, I'm a new Firebird user, using Firebird-1.5.0.4306-Win32 andThis statement will return one row with one field with content "null".
> Firebird-JDBC-SQL-1.5.0Beta3JDK_1.4.
>
> I have a new database , no data in it yet. When my application starts it
> looks for a value in the database, returning it if found, i.e something
> like:
>
> ...
> 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");
>
Try
ResultSet rs = s.executeQuery("select max(PK_SN) maxPKSN from MYTABLE");
if (rs.next())
// Then the row exists - return the value:
return rs.getInt("maxPKSN");
or
ResultSet rs = s.executeQuery("select max(PK_SN) maxPKSN from MYTABLE");
if (rs.next())
// Then the row exists - return the value:
return rs.getInt(1);
Stefan