-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE: td_sga_subcomisiones
-- Tabla: sga_subcomisiones
-- Version: 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftdb_sga_subcomisiones ();
CREATE OR REPLACE FUNCTION ftdb_sga_subcomisiones () RETURNS trigger AS 
$BODY$
   
BEGIN

   -- Borro tabla de cupos de la subcomision
   DELETE FROM sga_subcomisiones_cupo 
         WHERE subcomision = OLD.subcomision;

   RETURN OLD;
END;
$BODY$
LANGUAGE 'plpgsql';


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE sobre sga_subcomisiones
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tdb_sga_subcomisiones ON sga_subcomisiones RESTRICT;
CREATE TRIGGER tdb_sga_subcomisiones
       BEFORE DELETE ON sga_subcomisiones 
       FOR EACH ROW EXECUTE PROCEDURE ftdb_sga_subcomisiones();

