Subject | Re: The New command in triggers |
---|---|
Author | Adam |
Post date | 2006-02-15T01:35:57Z |
Graeme,
Do not reply to a post that has nothing to do with your comments.
1. It stuffs up newsreaders that organise automatically based on
replies.
2. People will not notice your post if they do not read Geoff's post
about "Read only databases and procedure blobs"
Instead of Reply, either click Post (web interface) or compose a new
email (from email client).
true. NULL is a state not a value You need to specifically check
whether the OLD and NEW context variables have the same NULL state if
that is of interest to you.
If you consider NULL = NULL for the purpose of comparison, then you
will need to check each field like this.
IF ((OLD.FIELD <> NEW.FIELD) OR
(OLD.FIELD IS NOT NULL AND NEW.FIELD IS NULL) OR
(OLD.FIELD IS NULL AND NEW.FIELD IS NOT NULL)) THEN .....
Adam
Do not reply to a post that has nothing to do with your comments.
1. It stuffs up newsreaders that organise automatically based on
replies.
2. People will not notice your post if they do not read Geoff's post
about "Read only databases and procedure blobs"
Instead of Reply, either click Post (web interface) or compose a new
email (from email client).
> I am currently having trouble developing a before update trigger toset a
> timestamp field in a record basedNEW.FIELD = OLD.FIELD
>
> on values in other fields.
>
> The question I need answered is
>
> What is stored in new.Field if no change has been made to Field?
> My logic seems to break down when I assume that new.Field=old.Fieldseems to
> indicates that no change has been made to the
>
> Field, and the possibility of Null in either new.Field or Old.Field
> complicate it more.Your logic breaks when you assume the statement (NULL = NULL) is
true. NULL is a state not a value You need to specifically check
whether the OLD and NEW context variables have the same NULL state if
that is of interest to you.
If you consider NULL = NULL for the purpose of comparison, then you
will need to check each field like this.
IF ((OLD.FIELD <> NEW.FIELD) OR
(OLD.FIELD IS NOT NULL AND NEW.FIELD IS NULL) OR
(OLD.FIELD IS NULL AND NEW.FIELD IS NOT NULL)) THEN .....
Adam