Subject | RE: [ib-support] OLD context variable behaviour on triggers |
---|---|
Author | Thomas Steinmaurer |
Post date | 2002-12-05T12:29:12Z |
Hugo,
have a look in the thread "trigger on a blob field" yesterday.
NULL values must be considered separately.
An general example to capture all possible value changes:
if (((OLD.COLUMN IS NULL) AND (NEW.COLUMN IS NOT NULL)) OR
((OLD.COLUMN IS NOT NULL) AND (NEW.COLUMN IS NULL)) OR
(OLD.COLUMN <> NEW.COLUMN)) THEN
Regards,
Thomas Steinmaurer
IB LogManager 2.1 - The Logging/Auditing Tool for InterBase and Firebird
http://www.iblogmanager.com
have a look in the thread "trigger on a blob field" yesterday.
NULL values must be considered separately.
An general example to capture all possible value changes:
if (((OLD.COLUMN IS NULL) AND (NEW.COLUMN IS NOT NULL)) OR
((OLD.COLUMN IS NOT NULL) AND (NEW.COLUMN IS NULL)) OR
(OLD.COLUMN <> NEW.COLUMN)) THEN
Regards,
Thomas Steinmaurer
IB LogManager 2.1 - The Logging/Auditing Tool for InterBase and Firebird
http://www.iblogmanager.com
> -----Original Message-----
> From: Hugo [mailto:hugosan@...]
> Sent: Thursday, December 05, 2002 1:00 PM
> To: ib-support@yahoogroups.com
> Subject: [ib-support] OLD context variable behaviour on triggers
>
>
> Firebird 1.0 Win32
> Let's suppose this table:
>
> CREATE TABLE PROVA(
> ID INTEGER NOT NULL PRIMARY KEY,
> ELMEUCAMP VARCHAR(8),
> HASCHANGED CHAR(1)
> );
>
> and this trigger:
>
> CREATE TRIGGER MyTriggerBU FOR PROVA
> BEFORE UPDATE AS
> BEGIN
>
> IF(OLD.ELMEUCAMP!=NEW.ELMEUCAMP) THEN
> NEW.HASCHANGED='X';
>
> END
>
> I'm find that, when I change ELMEUCAMP field value from NULL to something not null, the trigger doesn't perform the THEN
> statement !!
> It's to say, if OLD.FIELD=null and NEW.FIELD='ABCD', they are equals for the trigger.
>
> Is this normal? Maybe the problem is the VARCHAR type?
>
> Thanks in advance,
> Hugo.
>
>
> [Non-text portions of this message have been removed]
>
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>