CREATE OR REPLACE FUNCTION food600.pridajcuzavzprhores10()
    RETURNS trigger
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE NOT LEAKPROOF
AS $BODY$
DECLARE 
	old_idriadok INTEGER;
BEGIN
      
  IF (TG_OP = 'INSERT') THEN
	SELECT idriadok INTO old_idriadok FROM food600.pr_hores10_uzav WHERE c_data=NEW.c_data AND id_hotel=NEW.id_hotel and c_uzav=NEW.c_uzav;
	IF old_idriadok ISNULL THEN
		INSERT INTO food600.pr_hores10_uzav (c_data, id_hotel, c_uzav) VALUES (new.c_data, new.id_hotel,new.c_uzav) ;
	END IF;
  END IF;
        
  RETURN NEW;
END;
$BODY$;
