SET TERM ^ ;



CREATE OR ALTER TRIGGER RASPAGEM_CONFIGURACAO_QTD_THREA FOR RASPAGEM_CONFIGURACAO
ACTIVE BEFORE INSERT OR UPDATE POSITION 100
AS
BEGIN
  IF ((OLD.QTD_THREADS_PET_OFICIO IS DISTINCT FROM NEW.QTD_THREADS_PET_OFICIO)) THEN
  BEGIN
    IF (NEW.QTD_THREADS_PET_OFICIO > 5) THEN
    BEGIN
      NEW.QTD_THREADS_PET_OFICIO = 5;
    END
    ELSE
    IF (NEW.QTD_THREADS_PET_OFICIO < 1) THEN
    BEGIN
      NEW.QTD_THREADS_PET_OFICIO = 1;
    END
  END
END
^
SET TERM ; ^