CREATE OR REPLACE FUNCTION food600.zrkeeper_vrat(
	mcuzaverka integer,
	cdata integer)
    RETURNS smallint
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE 
AS $BODY$
BEGIN
DELETE FROM food600.sk__fin WHERE c_uzaverka=mcuzaverka AND c_data=cdata;
DELETE FROM food600.sk__pol WHERE c_uzaverka=mcuzaverka AND c_data=cdata;
DELETE FROM food600.sk__plt WHERE c_uzaverka=mcuzaverka AND c_data=cdata;
DELETE FROM food600.sk__sez WHERE c_uzaverka=mcuzaverka AND c_data=cdata;
DELETE FROM food600.sk__uza WHERE idriadok=mcuzaverka AND c_data=cdata;
UPDATE food600.rkeeper_uzavierky SET c_uzaverka=0 WHERE c_uzaverka=mcuzaverka;
UPDATE food600.rkeeper_uzavierky SET c_polot=0 WHERE c_polot=mcuzaverka;
RETURN 1;
END
$BODY$;
