Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 4th, 2004, 07:48 PM
tim snl's Avatar
tim snl tim snl is offline
Code Cruncher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Tasmania, Australia
Posts: 119 tim snl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 21 m 20 sec
Reputation Power: 8
Question Comparison with NULL

The book Using Firebird by IBPhoenix is talking about comparison operators and it says ...
Quote:
Comparisons evaluate to NULL if a NULL value is encountered on either the right or the left of the
operator.

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!

Reply With Quote
  #2  
Old November 5th, 2004, 02:55 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 21 h 42 m 49 sec
Reputation Power: 37
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

Reply With Quote
  #3  
Old November 6th, 2004, 12:40 AM
skidder skidder is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 15 skidder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to skidder
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Comparison with NULL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT