SET TERM ^ ;

CREATE trigger ttbgrade_b01iu for tbgrade
active before insert or update position 0
AS
BEGIN

    IF (NEW.T01 = '' AND NEW.T02 = '' AND NEW.T03 = '' AND NEW.T04 = '' AND NEW.T05 = '' AND
        NEW.T06 = '' AND NEW.T07 = '' AND NEW.T08 = '' AND NEW.T09 = '' AND NEW.T10 = '' AND
        NEW.T11 = '' AND NEW.T12 = '' AND NEW.T13 = '' AND NEW.T14 = '' AND NEW.T15 = '' AND
        NEW.T16 = '' AND NEW.T17 = '' AND NEW.T18 = '' AND NEW.T19 = '' AND NEW.T20 = '') THEN
    BEGIN

        EXCEPTION "..." 'NENHUMA TAMANHO PREENCHIDO. OPERACAO NAO AUTORIZADA!';

    END ELSE
    IF ((NEW.T01 = '' AND (NEW.T02 <> '' OR NEW.T03 <> '' OR NEW.T04 <> '' OR NEW.T05 <> '' OR NEW.T06 <> '' OR NEW.T07 <> '' OR NEW.T08 <> '' OR NEW.T09 <> '' OR NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T02 = '' AND (NEW.T03 <> '' OR NEW.T04 <> '' OR NEW.T05 <> '' OR NEW.T06 <> '' OR NEW.T07 <> '' OR NEW.T08 <> '' OR NEW.T09 <> '' OR NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T03 = '' AND (NEW.T04 <> '' OR NEW.T05 <> '' OR NEW.T06 <> '' OR NEW.T07 <> '' OR NEW.T08 <> '' OR NEW.T09 <> '' OR NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T04 = '' AND (NEW.T05 <> '' OR NEW.T06 <> '' OR NEW.T07 <> '' OR NEW.T08 <> '' OR NEW.T09 <> '' OR NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T05 = '' AND (NEW.T06 <> '' OR NEW.T07 <> '' OR NEW.T08 <> '' OR NEW.T09 <> '' OR NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T06 = '' AND (NEW.T07 <> '' OR NEW.T08 <> '' OR NEW.T09 <> '' OR NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T07 = '' AND (NEW.T08 <> '' OR NEW.T09 <> '' OR NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T08 = '' AND (NEW.T09 <> '' OR NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T09 = '' AND (NEW.T10 <> '' OR NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T10 = '' AND (NEW.T11 <> '' OR NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T11 = '' AND (NEW.T12 <> '' OR NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T12 = '' AND (NEW.T13 <> '' OR NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T13 = '' AND (NEW.T14 <> '' OR NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T14 = '' AND (NEW.T15 <> '' OR NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T15 = '' AND (NEW.T16 <> '' OR NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T16 = '' AND (NEW.T17 <> '' OR NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T17 = '' AND (NEW.T18 <> '' OR NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T18 = '' AND (NEW.T19 <> '' OR NEW.T20 <> '')) OR
        (NEW.T19 = '' AND (NEW.T20 <> ''))) THEN
    BEGIN

        EXCEPTION "..." 'ATENCAO! NAO PODEM HAVER INTERVALOS VAZIOS ENTRE OS TAMANHOS.';

    END

END
^

SET TERM ; ^

