Desencadenador de Oracle en tabla anidada

I want to create a trigger to validate the date of birth, for example it's not > SYSDATE:

Employee -- STRUCTURED TYPE
{
     name VARCHAR2(10)
     lastname VARCHAR(10)
     birthdate DATE
}

Employee_List TABLE OF Employee -- NESTED TABLE

Museum -- TABLE
{
     id NUMBER
     EmployeeList Employee_List
}

Estoy usando Oracle 10g.

preguntado el 27 de noviembre de 13 a las 02:11

Anything you've tried and that did not work? -

1 Respuestas

You cannot define a trigger like "BEFORE UPDATE ON Museum.EmployeeList.birthdate" But you can write a normal trigger BEFORE UPDATE ON Museum and in trigger body you can loop over all employees checking the date.

Prueba este:

CREATE OR REPLACE TRIGGER BUIR_Museum 
    BEFORE INSERT OR UPDATE ON Museum
    FOR EACH ROW

BEGIN
    IF :NEW.EmployeeList IS NOT NULL THEN
        FOR i IN :NEW.EmployeeList.FIRST..:NEW.EmployeeList.LAST LOOP
            IF :NEW.EmployeeList(i).birthdate > SYSDATE THEN
                RAISE_APPLICATION_ERROR(-20029, 'Invalid birthday');
            END IF;
        END LOOP;
    END IF;
END;

respondido 27 nov., 13:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.