Subject RE: [ib-support] trigger on a blob field
Author Thomas Steinmaurer
Hi Roger,

> Hi all
>
> Need to log if users have altered text in a blob field
> on a before update trigger something like...
>
> if (old.notes <> new.notes) then
> begin
> insert into
> log_notes
> (refnum,old_notes,new_notes)
> values
> (main_property.refnum,old.notes,new.notes);
> end
>
> works fine if there is "old" text already there
> but not if there is no text to start with
>
> Is this a limitation of memo (blob) fields??

According to a logging trigger created by IBLM ;-), NULL values
must be considered separately.

An general example:

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
...

Be aware, that BLOB column values can't be compared by using
the OLD and NEW context variables. You'll have to use a UDF
for this.

But hey, IBLM has already everything you need for realizing a
stable audit trail ;-).


Regards,
Thomas Steinmaurer
IB LogManager 2.1 - The Logging/Auditing Tool for InterBase and Firebird
http://www.iblogmanager.com