CREATE FUNCTION tr_raktar_mozgas_after_insert()
    RETURNS trigger
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE NOT LEAKPROOF
AS $BODY$
begin
      IF (new.mennyiseg_foglalasbol > 0) THEN
         PERFORM foglalas_rendezes(new.tetel_kod);
      END IF;
      IF (new.mennyiseg_rendelesre_erkezett > 0) THEN
         PERFORM rendeles_rendezes(new.tetel_kod);
      END IF;   	  

  return new;
end;$BODY$;

CREATE TRIGGER trigger_raktar_mozgas_after_insert
    AFTER INSERT
    ON raktar_mozgas
    FOR EACH ROW
    EXECUTE PROCEDURE public.tr_raktar_mozgas_after_insert();