Re: Using nulls in a jdbc Select
From: Charles Fineman (cfineman-no&spam_at_yahoo.com)
Date: 03/23/04
- Next message: JLParke: "Handling large record sets in JDBC/web app"
- Previous message: Charles Fineman: "Re: Datadirect JDBC driver on DB2: Locks not released"
- In reply to: Hugh von Kanada: "Using nulls in a jdbc Select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 23 Mar 2004 10:10:10 -0500
Unfortunately i think you can only use ISNULL for this. Sucks if you are
trying to keep around the prepared statement.
Hugh von Kanada wrote:
> Hi all,
> I need to do a select on a nullable column in a database where I
> absolutely must know if this column is null or not. I tried coming up
> with searches that get around it, but there is no way of searching and
> getting the unique results I require without checking this field.
>
> Now, the problem. I'm going against an MS SQL Server 2000 database
> using the Microsoft jdbc driver.
>
> I'm trying to do something like this:
>
> String strSQL = "DELETE FROM ContextDefinitions WHERE CONTEXT_DEF_ID =?
> AND BLOCK_ACT_DEF_ID";
> if (isBlock)
> strSQL += " !=?";
> else
> strSQL += " =?";
>
> stmt = getConnection().prepareStatement(strSQL);
> stmt.setInt(1, iContextId);
> stmt.setNull(2, java.sql.Types.INTEGER);
> int iRowsDel = stmt.executeUpdate();
>
> I can set the null, but then the query doesn't find the row in both the
> case where I set the second item to look for not null or null.
>
> I noticed that when I do the query in the MS SQL query tool, I can't
> locate null columns in a search. What's up with that??
> -Hugh
>
- Next message: JLParke: "Handling large record sets in JDBC/web app"
- Previous message: Charles Fineman: "Re: Datadirect JDBC driver on DB2: Locks not released"
- In reply to: Hugh von Kanada: "Using nulls in a jdbc Select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|