CREATE SEQUENCE ACTAS_GEN;
-----
ALTER TABLE ACTAS ADD NUMERO_ACTA INTEGER;
-----
CREATE OR ALTER TRIGGER ACTAS_BI FOR ACTAS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.NRO_ACTA IS NULL) THEN BEGIN
    NEW.NRO_ACTA = GEN_ID(ORDEN_GEN, 1);
  END
  NEW.NUMERO_ACTA = ((EXTRACT(YEAR FROM NEW.FECHA) - 2000) * 1000) + GEN_ID(ACTAS_GEN, 1);
END

