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