The NULL
literal
The ability to use NULL
literals depends on your Firebird version.
Firebird 1.5 and below
In Firebird 1.5 and below you can only use the literal word “NULL
” in a few situations, namely the ones described in the previous paragraphs plus a few others such as “cast( NULL as <datatype> )
” and “select NULL from MyTable
”.
In all other circumstances, Firebird will complain that NULL
is an unknown token.If you really must use NULL
in such a context, you have to resort to tricks like “cast( NULL as int )
”, or using a field or variable that you know is NULL
, etc.
Firebird 2.0 and up
Firebird 2 allows the use of NULL
literals in every context where a normal value can also be entered.You can e.g. include NULL
in an IN()
list, write expressions like “if ( MyField = NULL ) then…
”, and so on.However, as a general rule you should not make use of these new possibilities!In almost every thinkable situation, such use of NULL
literals is a sign of poor SQL design and will lead to NULL
results where you meant to get true
or false
.In that sense the earlier, more restrictive policy was safer, although you could always bypass it with casts etc. — but at least you had to take deliberate steps to bypass it.