CREATE OR REPLACE FUNCTION food600.sklad_zmena()
    RETURNS trigger
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE NOT LEAKPROOF
AS $BODY$
BEGIN
      
IF (TG_OP = 'UPDATE') THEN
	IF 
		(NEW.c_karty    != OLD.c_karty) OR
		(NEW.c_stredisk != OLD.c_stredisk)  OR
		(NEW.zustatek   != OLD.zustatek)  OR
		(NEW.cena_prum  != OLD.cena_prum) OR
		(NEW.vycisleni  != OLD.vycisleni) OR
		(NEW.min_zaso   != OLD.min_zaso) OR
		(NEW.max_zaso   != OLD.max_zaso) 
		THEN
			NEW.zmena := current_timestamp;
			PERFORM food600.f_zmeny_tab('sklad',NEW.zmena,NEW.c_data);
	END IF;   
ELSIF (TG_OP = 'INSERT') THEN
	NEW.zmena := current_timestamp;
	PERFORM food600.f_zmeny_tab('sklad',NEW.zmena,NEW.c_data);
END IF;
RETURN NEW;
END;
$BODY$;
