CREATE OR REPLACE FUNCTION food600.fidelio_yes_zav(
	)
    RETURNS integer
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE
AS $BODY$
DECLARE pocetriadkov INTEGER;
BEGIN
UPDATE food600.db_out SET stav='RU' WHERE typ='ZATIZ' AND SUBSTRING(ucet_kasa FROM 3 FOR 1)='U' AND BTRIM(pm)<>''
	AND postseqnr IN (SELECT postseqnr FROM food600.db_in WHERE BTRIM(cis_kasy)='' OR odpoved<>'OK');
GET DIAGNOSTICS pocetriadkov = ROW_COUNT;
RETURN pocetriadkov;
END
$BODY$;
