\encoding UTF8
COPY (SELECT query_to_xml('SELECT tt.tetel_kod as product_id, ttk.kod as atribute_id, ttk.tulajdonsag as name, tt.tulajdonsag as value
  FROM tetel_tulajdonsag tt
  INNER JOIN tetel_tulajdonsagok ttk ON ttk.kod = tt.tulajdonsag_kod
  INNER JOIN tetel t ON t.kod = tt.tetel_kod AND t.hasznalatban >= 0
  WHERE (not(tt.tulajdonsag = ''''))
   AND (t.tetel_kapcsolat_szulo = 0)
   AND ((tt.lasteditedtime_forsync + interval ''12 hours'') > current_timestamp)
UNION ALL
SELECT t.tetel_kapcsolat_szulo as product_id, ttk.kod as atribute_id, ttk.tulajdonsag as name, tt.tulajdonsag as value
  FROM tetel_tulajdonsag tt
  INNER JOIN tetel_tulajdonsagok ttk ON ttk.kod = tt.tulajdonsag_kod
  INNER JOIN tetel t ON t.kod = tt.tetel_kod AND t.hasznalatban >= 0
  WHERE (not(tt.tulajdonsag = ''''))
   AND (t.tetel_kapcsolat_szulo <> 0)
   AND ((tt.lasteditedtime_forsync + interval ''12 hours'') > current_timestamp)
ORDER BY 1,2', true, false, '')) to '/tmp/flexovit_tetel-tulajdonsag_changed.xml'