From: | Thomas O'Dowd <tom(at)nooper(dot)com> |
---|---|
To: | Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp> |
Cc: | pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: res.wasNull() troubles when using CASE? |
Date: | 2002-11-13 03:56:52 |
Message-ID: | 1037159812.23889.90.camel@beast.uwillsee.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
You have to call a getXXX() method first. wasNUll works with the last
column that was read.
Tom.
On Wed, 2002-11-13 at 12:33, Jean-Christian Imbeault wrote:
> I have the following query which seems to be having trouble with
> ResultSet.wasNull():
>
> String sql = "select case when date_sent is not null then
> to_char(date_sent::timestamp, 'YY-mm-DD HH:MI') else null end as
> date_sent from invoice_emails where invoice_id='" + id + "' order by
> date_sent";
>
> String s;
> ResultSet res = db.queryDB(sql);
> try {
> while (res.next()) {
> if (res.wasNull()) {
> s = new String("Pending");
> dates.add(s);
> }
> else {
> s = res.getString("date_sent");
> dates.add(s);
> }
> }
> System.out.println(s);
> }
> catch (SQLException e) {System.out.println("ERROR");}
>
> When the returned value is null, the if (res.wasNull()) clause does not
> get executed ... but the value truly was null since when I print String
> s it is null.
>
> I tried the same query using the command line and it does return null
> when the date_sent column is null ... the JDBC driver however doesn't
> seem to realize this ...
>
> I'm sure it's my fault though. Can someone tell me where I went wrong?
>
> Thanks!
>
> Jc
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
--
Thomas O'Dowd, CEO, Nooper.com - Mobile Services Inc., Tokyo, Japan
i-mode & FOMA consulting, development, testing: http://nooper.co.jp/
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Lamb | 2002-11-13 10:03:02 | setUseServerPrepare & typecasts |
Previous Message | Jean-Christian Imbeault | 2002-11-13 03:33:35 | res.wasNull() troubles when using CASE? |