Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PAQUETE.
- CREATE OR REPLACE PACKAGE paqejer4
- IS
- v_linea_tren NUMBER(5);
- v_linea_estacion NUMBER(5);
- END paqejer4;
- /
- // TRIGGER 1.
- CREATE OR REPLACE TRIGGER ejer4_1
- before INSERT OR DELETE ON tren
- FOR each ROW
- BEGIN
- SELECT COUNT(*) INTO paqejer4.v_linea_estacion FROM linea_estacion WHERE linea = :NEW.linea;
- SELECT COUNT(*) INTO paqejer4.v_linea_tren FROM tren WHERE linea = :NEW.linea;
- END;
- /
- // TRIGGER 2.
- CREATE OR REPLACE TRIGGER ejer4_2
- before INSERT OR DELETE ON tren
- FOR each ROW
- BEGIN
- IF inserting THEN
- IF (paqejer4.v_linea_tren > (paqejer4.v_linea_estacion*2)) THEN
- raise_application_error(-20500,'Imposible insertar el tren. La línea no soporta más trenes.');
- END IF;
- END IF;
- IF deleting THEN
- IF (paqejer4.v_linea_tren < paqejer4.v_linea_estacion) THEN
- raise_application_error(-20500,'Imposible Borrar el tren. No puede haber menos trenes que estaciones.');
- END IF;
- END IF;
- END;
- /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement