\encoding UTF8
COPY (SELECT query_to_xml('SELECT rm.tetel_kod as product_id, rmf.partner_kod as customer_id, round(rm.netto_egysegar,2) as price, round(rm.mennyiseg) as qty, rmf.datum1 as date_start, rmf.datum2+1 as date_end
   FROM raktar_mozgas_fej rmf
   INNER JOIN raktar_mozgas rm ON rm.fej_kod = rmf.kod
   INNER JOIN partner p ON p.kod = rmf.partner_kod AND (not(p.webbolt_userid = '''')) AND (not(p.webbolt_userid is null))
   WHERE rmf.bizonylat_fajta = 10
     AND rmf.rendben = 2
     AND rmf.sztornozott_bizonylat_kod = 0
     AND rmf.sztornozo_bizonylat_kod = 0
     AND rmf.datum1 <= current_date
     AND rmf.datum2 >= current_date', true, false, '')) to '/tmp/flexovit_tetel-egyediar.xml'