CREATE OR REPLACE FUNCTION food600.updatepolaboolean(
	oldpole boolean,
	newpole boolean,
	INOUT pocet integer,
	INOUT navrat character varying,
	INOUT navrat_master character varying,
	meno character varying)
    RETURNS record
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE PARALLEL UNSAFE
AS $BODY$
BEGIN
IF (newpole != oldpole) THEN 
	IF pocet>0 THEN
		navrat:=navrat||',';
		navrat_master:=navrat_master||',';
	END IF;
	IF newpole THEN
		navrat:=navrat||meno||'=CAST(1 as boolean)';
		navrat_master:=navrat_master||meno||'=CAST(1 as boolean)';
	ELSE
		navrat:=navrat||meno||'=CAST(0 as boolean)';
		navrat_master:=navrat_master||meno||'=CAST(0 as boolean)';
	END IF;
	pocet:=pocet+1;
END IF;
END
$BODY$;
