SET SQL DIALECT 3;

SET NAMES WIN1251;

CONNECT 'localhost:D:\1111111111111111\TOPAZOFFICE.FDB' USER 'SYSDBA' PASSWORD 'electro';

CREATE OR ALTER trigger "sysUsersGenHash" for "sysUsers"
inactive before insert or update position 4
AS
BEGIN /*$$IBE$$ 
  IF (UPDATING AND(NEW."Login"=OLD."Login")AND(NEW."Deleted"=OLD."Deleted")) THEN EXIT;
  IF (NEW."Deleted" IS NULL) THEN
    NEW."Hash" = MD5(NEW."Login");
  ELSE
    NEW."Hash" = MD5(NEW."Login"||NEW."Deleted");
 $$IBE$$*/ POST_EVENT '$$IBE$$';
END;

commit;