Page 1 of 1

Pass NULL value to query parameters

Posted: Mon 12 Jan 2009 11:27
by edvanwijngaarden
Hello,

My question seems simple, but I have not found an appropriate answer after a lot of searching:
how can I pass a null-value to a (date-) parameter of a query?
I need to make a selelction on date, but it must also be possible to select records where the datefield is not filled in (Null).
In the sql-text I use someting like: "...LOAD_DATE=:Date1.."
This works OK for normal dates, but I cannot pass NULL as a parameter value, because the SQL syntax must be: "...LOAD_DATE IS NULL.."
and not: "...LOAD_DATE=NULL..".
I can do a workaround by changing the complete SQL text in code, but there must be a simpler way???

Ed van Wijngaarden

Posted: Tue 13 Jan 2009 09:18
by Plash
You should change your SQL text. LOAD_DATE=:Date1 cannot be used because it never returns True when both field and parameter are Null.
Use the following check:

Code: Select all

LOAD_DATE=:Date1 OR (LOAD_DATE IS NULL AND :Date1 IS NULL)