Re: Possible regression: setNull() usage changed from 7.4

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: Jeff Hubbach <jeff(dot)hubbach(at)chha(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Possible regression: setNull() usage changed from 7.4
Date: 2006-04-14 15:32:31
Message-ID: 443FC08F.8020505@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi, Jeff,

Jeff Hubbach wrote:

> select count(*) from users where usernam = ? and
> (?::integer is null or userid != ?)
>
> stmt.setString(1,'blah');
> stmt.setNull(2,java.sql.Types.NULL);
> stmt.setNull(3,java.sql.Types.NULL);
>
> This code gives the server the type information it needs by doing an
> explicit cast. It seems to work, but was wondering if there are any
> problems you see with it (or if you have a better/cleaner way to go
> about it).

The correct way, IMHO, would be to use two different prepared
statements, one with the userid, and another one without.

HTH,
Markus

--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Goodenough 2006-04-14 18:21:51 What is the number equivalient of LIMIT ALL
Previous Message Jeff Hubbach 2006-04-14 14:53:07 Re: Possible regression: setNull() usage changed from 7.4 to