INSERT INTO szszb (bizonylat_fajta, ev, szam, datum, ido)
     select bizonylat_fajta, CAST(substring(bizonylatszam from 1 for 4) AS integer) as ev,
            CAST(substring(bizonylatszam from 6 for 7) AS integer) as szam, datum, ido 
         from raktar_mozgas_fej where bizonylat_fajta in (2,3,4,5,9,10,11,12,13);

INSERT INTO szszb (bizonylat_fajta, ev, szam, datum, ido)
     select 1, CAST(substring(raktar_mozgas_bizonylat from 1 for 4) AS integer) as ev,
            CAST(substring(raktar_mozgas_bizonylat from 6 for 7) AS integer) as szam, datum, ido 
         from raktar_mozgas_fej where raktar_mozgas_bizonylat <> ''; 