-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE: tdb_sga_comisiones_bh
-- BEFORE DELETE
-- Tabla: sga_comisiones_bh
-- Version: 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftdb_sga_comisiones_bh ();
CREATE OR REPLACE FUNCTION ftdb_sga_comisiones_bh () RETURNS trigger AS 
$BODY$
BEGIN
   -- Borro las clases de la banda horaria
   DELETE FROM sga_clases WHERE banda_horaria = OLD.banda_horaria;
   
   RETURN OLD;
END;
$BODY$
LANGUAGE 'plpgsql';


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de DELETE sobre sga_comisiones_bh
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tdb_sga_comisiones_bh ON sga_comisiones_bh RESTRICT;
CREATE TRIGGER tdb_sga_comisiones_bh
       BEFORE DELETE ON sga_comisiones_bh 
       FOR EACH ROW EXECUTE PROCEDURE ftdb_sga_comisiones_bh();

