begin for cr in ( select x03.xsddhm from xst03 x03 left join kct98 t98 on t98.xsddhm = x03.xsddhm left join kcm07 m7 on t98.kccxdm = m7.kccxdm and t98.kcppai = m7.kcppai left join kcm05 m5 on m7.kcxlie = m5.kcxlie and m7.kcppai = m5.kcppai left join xst34 x34 on x03.xsddhm = x34.xskhdd left join xsm12 m12 on x03.xsjslx = m12.xsjsdm where 1 = 1 and x03.xsddzt in ('F', 'G') and x03.xspczt = 'C' and x34.xspzph is null and m12.xszjlx = 'ZS' and x03.kcppai = 'ORV' and x03.xspcrq > 20140602 AND t98.kcckrq<20190601 ) loop insert into xst34 values ('00',cr.xsddhm,null,null); end loop; commit; end;