
CREATE TABLE ALUMNOS_PLANES (
    NRO_ALUMNO_PLAN          INTEGER NOT NULL,
        NRO_ALUMNO  INTEGER,
    NRO_PLAN     INTEGER,
    LIBRO        INTEGER,
    FOLIO        INTEGER,
    ACTIVO       INTEGER
);
-----

ALTER TABLE ALUMNOS_PLANES ADD CONSTRAINT PK_ALUMNOS_PLANES PRIMARY KEY (NRO_ALUMNO_PLAN);
-----

ALTER TABLE ALUMNOS_PLANES ADD CONSTRAINT FK_ALUMNOS_PLANES FOREIGN KEY (NRO_ALUMNO) REFERENCES ALUMNOS (NRO_ALUMNO);
-----
ALTER TABLE ALUMNOS_PLANES ADD CONSTRAINT FK_ALUMNOS_PLANES1 FOREIGN KEY (NRO_PLAN) REFERENCES PLANES (NRO_PLAN);
-----
CREATE OR ALTER TRIGGER ALUMNOS_PLANES_BI FOR ALUMNOS_PLANES
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  NEW.NRO_ALUMNO_PLAN = GEN_ID(ORDEN_GEN, 1);
END