CREATE OR REPLACE FUNCTION food600.setzadankamnozstvi(
	cdata integer,
	cstredisk integer,
	mmeno character varying)
    RETURNS integer
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE
AS $BODY$
BEGIN
UPDATE food600.buffer SET mnozstvi=(sklad.max_zaso-sklad.zustatek) FROM food600.sklad WHERE buffer.c_karty=sklad.c_karty and buffer.c_data=cdata and buffer.menobuf=mmeno and sklad.c_stredisk=cstredisk and sklad.min_zaso>0 and sklad.zustatek<sklad.max_zaso;
RETURN 1;
END
$BODY$;
