update t00, z_tameia_t00
set t00.p201 = z_tameia_t00.p201 
where t00.p01=z_tameia_t00.p01;
/*peg_end*/

insert into t00
(nr01, p01, p02, p000, p201, 
remdate, remtime, remuser, remfdate, remftime, remfuser)

select z_tameia_t00.nr01 as nr01, 
       z_tameia_t00.p01 as p01, 
       z_tameia_t00.p02 as p02, 
       z_tameia_t00.p000 as p000, 
       z_tameia_t00.p201 as p201, 

       curdate() as remdate, 
       curtime() as remtime, 
       z_tameia_t00.remuser as remuser, 
       z_tameia_t00.remfdate as remfdate, 
       z_tameia_t00.remftime as remftime, 
       z_tameia_t00.remfuser as remfuser 

from z_tameia_t00
LEFT JOIN t00 ON t00.p01=z_tameia_t00.p01
WHERE t00.nr01 is null;
/*peg_end*/
