CREATE OR REPLACE FUNCTION food600.dorobprepocet(
	)
    RETURNS void
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE 
AS $BODY$
DECLARE prik character varying(1000);
	zaznam integer;
	minriadok integer;
	mxl_done integer;
BEGIN
mxl_done := 10000;
WHILE (mxl_done>0) LOOP
	SELECT MIN(riadok) INTO minriadok FROM food600.prikazy_prepocet LIMIT 1;
	IF minriadok IS NULL THEN
		mxl_done:=0;
	ELSE 
		SELECT prikaz, idriadok INTO prik, zaznam FROM food600.prikazy_prepocet WHERE riadok=minriadok ORDER BY idriadok LIMIT 1;
		IF prik ISNULL THEN
			mxl_done:=0;
		ELSE
			EXECUTE prik;
			DELETE FROM food600.prikazy_prepocet WHERE idriadok=zaznam;
			--mxl_done:=0;
		END IF;
	END IF;
END LOOP;
END
$BODY$;
