Subject RE: [Firebird-general] Blobs in Triggers
Author Nigel Weeks
> >
> > I'm having trouble detecting if a BLOB has changed in an
> update trigger.
> >
> > I've tried the following:
> > If(NEW.blobfield != OLD.blobfield)THEN If(cast(NEW.blobfield AS
> > VARCHAR(32000)) != cast(OLD.blobfield AS
> > VARCHAR(32000))) THEN
> >
> > And a few others, to no avail.
> >
> > Is it even possible?
> It may be possible in the support list instead.
> :-)
> The problem is that I screwed the thing in FB1. I couldn't
> find any reference to how blobs and cast or substring would
> work with blobs. This only was clear when we were doing FB1.5
> and Arno or Nickolay posted parts of the recent SQL standard.
> The doco says that substring of blob should be blob. Instead,
> I made it produce a string in FB1. I guess then that the
> correct way to convert a blob to string would be using a cast
> like you tried to do, but we don't support it.
> There's enhanced (and fixed) functionality in FB2 that may
> allow you to do the blob comparison directly, even if
> expensive with large blobs.
> Ohtherwise, if you want to rely on current FB1.5
> functionality, you could try substring. Anyway, since you're
> limiting the conversion to 32K bytes, if the blob is bigger,
> you get unreliable results. Try FB2 and see if direct
> comparison of blob v/s blob or blob v/s string works as expected.
> C.

FB2 might be the thing to wait for then.