Subject | Re: Query returning row when it shouldn't... |
---|---|
Author | phil_sorry_trouble_with_profile |
Post date | 2004-05-31T06:33:08Z |
No, the problem isn't in getting the column value (errr... except that
this gives you an exception ;-) ) - problem is that rs.next() says
"sure, there's a row" which is not true.
--- In firebird-support@yahoogroups.com, "C Fraser"
<Colin.Fraser@h...> wrote:
this gives you an exception ;-) ) - problem is that rs.next() says
"sure, there's a row" which is not true.
--- In firebird-support@yahoogroups.com, "C Fraser"
<Colin.Fraser@h...> wrote:
> I am not sure, but I shall have a quick stab...MAX()...
>
> How do you know the name of the column is PK_SN? If I do a select
> In my DB Tool, the column name returned is "MAX"... Whenever I dothis in
> code, I usually just grab the first column returned... Not sure injava, but
> Delphi might be something like Fields[0].AsInteger...result
>
> May or may not be the problem...
>
> Regards
> Colin
>
> -----Original Message-----
> From: Phil [mailto:time_lord@h...]
> Sent: Monday, 31 May 2004 3:55 p.m.
> To: firebird-support@yahoogroups.com
> Cc: Firebird-Java@yahoogroups.com
> Subject: [firebird-support] Query returning row when it shouldn't...
>
> Hi, I'm a new Firebird user, using Firebird-1.5.0.4306-Win32 and
> 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");
>
> However an exception occurs on the last line:
> "org.firebirdsql.jdbc.FBSQLException: Column name PK_SN not found in
> set"problem is
> This in itself is not a suprise because there are no rows... the
> that rs.next() should return false (indicating that there is not a'next'
> row).
>
> Can anyone confirm that this is a bug and suggest the 'firebird' way of
> doing it? (This sort of thing works properly with SQLserver )
>
> TIA
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor --------------------~-->
> Yahoo! Domains - Claim yours for only $14.70
> http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/67folB/TM
> --------------------------------------------------------------------~->
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
> ######################################################################
> Attention:
> The information in this email and in any attachments is confidential.
> If you are not the intended recipient then please do not distribute,
> copy or use this information. Please notify us immediately by return
> email and then delete the message from your computer.
> Any views or opinions presented are solely those of the author.
> ######################################################################