Subject | Re: problem: PreparedStatement with "? IS NULL" |
---|---|
Author | bullitenergy |
Post date | 2004-09-23T11:05:23Z |
Hello Roman!
Maybe my code is a little bit strange. I tried to do the same as some
VS.NET generated code, but ADO.NET uses named parameters.
WHERE column = :value OR (column IS NULL AND :value IS NULL)
with one parameter assignment makes more sense than
WHERE column = ? OR (column IS NULL AND ? IS NULL)
because there are 2 parameters to assign with the same value.
I found out that i can workaround by using:
WHERE column = ? OR (column IS NULL AND ? = 0)
and instead of using a setNull for the second parameter, i use a
setInt that is 0 on a null value and 1 on something else.
Thank you for your reply and all your Jaybird work!
Best regards,
Bullet Energy
Maybe my code is a little bit strange. I tried to do the same as some
VS.NET generated code, but ADO.NET uses named parameters.
WHERE column = :value OR (column IS NULL AND :value IS NULL)
with one parameter assignment makes more sense than
WHERE column = ? OR (column IS NULL AND ? IS NULL)
because there are 2 parameters to assign with the same value.
I found out that i can workaround by using:
WHERE column = ? OR (column IS NULL AND ? = 0)
and instead of using a setNull for the second parameter, i use a
setInt that is 0 on a null value and 1 on something else.
Thank you for your reply and all your Jaybird work!
Best regards,
Bullet Energy