CREATE OR REPLACE FUNCTION food600.zhores10_vrat(
	muzaverka character varying,
	midkas character varying,
	cdata integer)
    RETURNS smallint
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE
AS $BODY$
DECLARE cuz INTEGER;
BEGIN
SELECT idriadok INTO cuz FROM food600.sk__uza WHERE uzaverka=muzaverka and id_kas=midkas AND c_data=cdata;
DELETE FROM food600.sk__fin WHERE c_uzaverka=cuz AND c_data=cdata;
DELETE FROM food600.sk__pol WHERE c_uzaverka=cuz AND c_data=cdata;
DELETE FROM food600.sk__plt WHERE c_uzaverka=cuz AND c_data=cdata;
DELETE FROM food600.sk__sez WHERE c_uzaverka=cuz AND c_data=cdata;
DELETE FROM food600.sk__uza WHERE uzaverka=muzaverka and id_kas=midkas AND c_data=cdata;
RETURN 1;
END
$BODY$;
