\encoding UTF8
SELECT foglalas_rendezes(data.tetel_kod)
  FROM (SELECT rm.tetel_kod
         FROM raktar_mozgas_fej rmf
         INNER JOIN raktar_mozgas rm ON rm.fej_kod = rmf.kod
         WHERE rmf.sztornozott_bizonylat_kod <> 0
          AND rm.mennyiseg <> 0
          AND rmf.c_date = current_date
         GROUP BY 1) data;
