Re: impossible to update rows specifying columns with NULL

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Guillaume Cottenceau <gc(at)mnc(dot)ch>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: impossible to update rows specifying columns with NULL
Date: 2005-03-01 11:31:22
Message-ID: 4224528A.3010606@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Guillaume Cottenceau wrote:
> Oliver Jowett <oliver 'at' opencloud.com> writes:
>
>
>>Guillaume Cottenceau wrote:
>>
>>
>>>The problem is when trying to UPDATE (changing values of other
>>>columns): my PreparedStatement uses "... WHERE column = ?" to
>>>specify the NULL value for the said column,
>>
>>You can't do that and get the results you expect. "column = NULL" is
>>never true (because "NULL = NULL" is false). You should use IS NULL to
>>match a NULL value.
>
> It's a pity. This would be very helpful.

Unfortunately, that's just the way that SQL NULLs work..

> With such situation, we
> can't use the same prepared-statement to match NULL and non-NULL
> values then, or I missed something?

You are correct.

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message sandrigo.lezcano@gmail.com 2005-03-01 11:43:05 string de conexao em JAVA
Previous Message Guillaume Cottenceau 2005-03-01 09:05:22 Re: impossible to update rows specifying columns with NULL value?