INSERT INTO i07
(nr01, p01, p02, vp02, pc01, vpc01, pm01, vpm01,  
remfdate, remftime, remfuser, remdate, remtime, remuser)
/*****************************
  products with no color
*****************************/  
SELECT * 
FROM (

SELECT peg_new_nr01('i07', 1) as nr01,
       i16.p00 as p01, 
       i00.pno as p02, 
       substr(i00.name, 1, 100) as vp02, 
       '' as pc01, 
       '' as vpc01, 
       '' as pm01,
       '' as vpm01,
       curdate() as remfdate, 
       curtime() as remftime, 
       '{user_pswd}' as remfuser, 
       curdate() as remdate, 
       curtime() as remtime, 
       '{user_pswd}' as remuser
FROM i00
LEFT JOIN i16 ON i16.p00>={np_apo1} 
              && i16.p00<={np_apo2}
LEFT JOIN i07 ON i07.p01=i16.p01
              && i07.p02=i00.pno
              && i07.pc01=''
              && i07.pm01=''
WHERE i00.p202=0
   && i00.p203=0
   && i07.nr01 is null
) as tbl   ;           
/*peg_end*/       