insert into t16
(nr01, p02, 
remdate, remtime, remuser, remfdate, remftime, remfuser)
select z_tameia_t16.nr01 as nr01, 
       z_tameia_t16.p02 as p02, 
       
       curdate() as remdate, 
       curtime() as remtime, 
       z_tameia_t16.remuser as remuser, 
       z_tameia_t16.remfdate as remfdate, 
       z_tameia_t16.remftime as remftime, 
       z_tameia_t16.remfuser as remfuser 
FROM z_tameia_t16
LEFT JOIN t16 ON t16.nr01=z_tameia_t16.nr01
WHERE t16.nr01 is null      

/*peg_end*/


set @n1:= (select max(nr01) from t16) ;
/*peg_end*/

update p07 set p010=@n1 where p01='t16';
/*peg_end*/
