|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
The book Using Firebird by IBPhoenix is talking about comparison operators and it says ...
Quote:
What does this mean? I have a timestamp field which may be NULL or it may have a date in it. I want to do the comparison (NEW.FIELD <> OLD.FIELD) in a trigger. If one of these values is NULL what is the result of the comparison. I need the comparison above to return TRUE if OLD.FIELD = NULL and NEW.FIELD = a date. Please help me understand this.
__________________
Beware of a programmer with a screwdriver! |
|
#2
|
|||
|
|||
|
Code:
NEW.FIELD <> OLD.FIELD will return UNKNOWN if either of the operands is null. Code:
NEW.FIELD <> OLD.FIELD or OLD.FIELD is null |
|
#3
|
|||
|
|||
|
In Firebird 1.5 (stable) you can compare it using construct like
COALESCE(new.field, 0) <> COALESCE(old.field, 0) In Firebird 2.0 (development) you can also use another standard SQL construct for the same purpose: new.field IS DISTINCT FROM old.field |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Comparison with NULL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|