CREATE OR ALTER TRIGGER TTBNFS_PARCELAMENTO00IU FOR TBNFS_PARCELAMENTO
ACTIVE BEFORE INSERT OR UPDATE POSITION 0
AS
DECLARE VARIABLE CLASSIFICACAO_NF VARCHAR(20);
BEGIN

    SELECT FIRST 1
        T.CLASSIFICACAO
    FROM TBNFS T
    WHERE T.CONTROLE = NEW.NFS_CONTROLE
    INTO :CLASSIFICACAO_NF;

    IF(CHAR_LENGTH(:CLASSIFICACAO_NF) > 0)THEN
    BEGIN
        NEW.CLASSIFICACAO = TRIM(:CLASSIFICACAO_NF);
    END
END;

CREATE OR ALTER trigger ttbnfe_parcelamento00iu for tbnfe_parcelamento
active before insert or update position 0
AS
DECLARE VARIABLE CLASSIFICACAO_NF VARCHAR(20);
BEGIN

    SELECT FIRST 1
        T.CLASSIFICACAO
    FROM TBNFE T
    WHERE T.CONTROLE = NEW.NFE_CONTROLE
    INTO :CLASSIFICACAO_NF;

    IF(CHAR_LENGTH(:CLASSIFICACAO_NF) > 0)THEN
    BEGIN
        NEW.CLASSIFICACAO = TRIM(:CLASSIFICACAO_NF);
    END

END;