-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de INSERT: tia_sga_alumnos_orient
-- AFTER INSERT
-- Tabla: sga_alumnos_orient
-- Version: 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftia_sga_alumnos_orient ();
CREATE OR REPLACE FUNCTION ftia_sga_alumnos_orient () RETURNS trigger AS 
$BODY$
BEGIN
  -- Registro la baja de la orientacion
  INSERT INTO sga_alumnos_orient_mov (alumno, orientacion, fecha, tipo_movimiento)
       VALUES (NEW.alumno, NEW.orientacion, NEW.fecha, 'Alta');
   
  RETURN NEW;
END;
$BODY$
LANGUAGE 'plpgsql';


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de INSERT sobre sga_alumnos_orient
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tia_sga_alumnos_orient ON sga_alumnos_orient RESTRICT;
CREATE TRIGGER tia_sga_alumnos_orient
       AFTER INSERT ON sga_alumnos_orient 
       FOR EACH ROW EXECUTE PROCEDURE ftia_sga_alumnos_orient();

