Subject Re: [Firebird-Java] delete with null not executed
Author Roman Rokytskyy
Hi,

> DELETE FROM "Prezzi" WHERE PR_IDORG=? AND PR_IDEVE=? AND PR_OP=? AND
> PR_TT=? AND PR_CAUSALE=?
>
> I set the parameters using setObject(index, value)
>
> The query is executed as a preparedStatement.executeUpdate()
>
> My problem is that the preparedStatement.executeUpdate()
> returns 1 (success since i delete 1 record at a time) only when all
> the parameters are not null (in this case it returns 0).

If you get 0, it means that the logic in your DELETE is wrong and you
have no entry where one of the listed fields contains NULL.

Note, setting parameter to NULL does not tell server to ignore the
parameter condition, but to match the record with NULL in the specified
field.

> Looking at the driver code it seems that using setNull is pointless
> since setObject can handle nulls by itself.

Correct.

Roman