CREATE OR REPLACE FUNCTION food600.nastav_text(ip_kluc character varying, ip_hodnota character varying)
 RETURNS boolean
 LANGUAGE plpgsql
  COST 100
AS $function$
DECLARE li_pocet integer default 0;

BEGIN
select count(*) into li_pocet from food600.texty where btrim(kluc)=btrim(ip_kluc) and btrim(modul) = 'FOOD';

IF li_pocet=0 THEN
 insert into food600.texty(kluc,hodnota,modul) values (btrim(ip_kluc),ip_hodnota,'FOOD');	
ELSE
 update food600.texty set hodnota = ip_hodnota where btrim(kluc)= btrim(ip_kluc) and btrim(modul) = 'FOOD';
END IF;
RETURN true;
END
$function$;
