CREATE OR REPLACE FUNCTION food600.napln_skl_buf(
	cdata integer)
    RETURNS integer
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE
AS $BODY$
BEGIN
DELETE FROM food600.skl_buf WHERE c_data=cdata;
INSERT INTO food600.skl_buf (c_stredisk, c_karty, zustatek, cena_prum, min_zaso, max_zaso, c_mena, c_data) SELECT c_stredisk, c_karty, 0 as zustatek, cena_prum, min_zaso, max_zaso, c_mena, c_data FROM food600.sklad WHERE c_data=cdata;
RETURN 1;
END
$BODY$;
