Re: Possible regression: setNull() usage changed from 7.4 - Mailing list pgsql-jdbc

From Markus Schaber
Subject Re: Possible regression: setNull() usage changed from 7.4
Date
Msg-id 443FC08F.8020505@logix-tt.com
Whole thread Raw
In response to Re: Possible regression: setNull() usage changed from 7.4 to  (Jeff Hubbach <jeff.hubbach@chha.com>)
List 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

pgsql-jdbc by date:

Previous
From: Jeff Hubbach
Date:
Subject: Re: Possible regression: setNull() usage changed from 7.4 to
Next
From: David Goodenough
Date:
Subject: What is the number equivalient of LIMIT ALL