a:1:{i:0;a:7:{s:7:"cod_prj";s:7:"Veratex";s:6:"versao";s:1:"1";s:7:"cod_apl";s:28:"fv2_beam_dummyposrec_restore";s:4:"nome";s:9:"onExecute";s:4:"tipo";s:1:"E";s:5:"parms";s:0:"";s:6:"codigo";s:1662:"$trunkit="Truncate wstemp";
sc_exec_sql($trunkit);
sc_exec_sql("
INSERT INTO wstemp 
(p_o_number) 
SELECT 
(p_o_number)
FROM sets
");
sc_exec_sql("
DELETE a
FROM wstemp as a, wstemp as b
WHERE
          (a.p_o_number = b.p_o_number)
      AND a.ID2 < b.ID2
");

sc_exec_sql("
UPDATE wstemp
	SET
	invoice = concat('X',p_o_number),adate = curdate()
");
sc_exec_sql("
UPDATE sets
	SET
	invoice = concat('X',p_o_number)
");
$update_wstemp_sets= 
"
UPDATE wstemp c
INNER JOIN 
(SELECT invoice, max(date)as ldate
  FROM sets
  GROUP BY invoice)
x ON c.invoice = x.invoice
SET c.date=x.ldate
";
sc_exec_sql($update_wstemp_sets);
$trunkit="Truncate warppo";
sc_exec_sql($trunkit);
sc_exec_sql("
INSERT INTO warppo 
(p_o_number) 
SELECT 
(p_o_number)
FROM wstemp
");
$update_warppo_wstemp= 
"
UPDATE warppo c
INNER JOIN 
(SELECT p_o_number, max(date)as ldate
  FROM wstemp
  GROUP BY p_o_number)
x ON c.p_o_number = x.p_o_number
SET c.date=x.ldate
";
sc_exec_sql($update_warppo_wstemp);$update_warppo_sets= 
"
UPDATE warppo c
INNER JOIN 
(SELECT p_o_number,ENDS as ends2,den as den2,fil as fil2, luster as luster2,producer as producer2,fiber as fiber2,merge as merge2,ship_to as shipto2,sets.TO as sup2,size as size2,b_s as bs2
  FROM sets
  GROUP BY p_o_number)
x ON c.p_o_number = x.p_o_number
SET c.EPB=x.ends2,c.den=x.den2,c.fil=x.fil2,c.luster=x.luster2,c.producer=x.producer2,c.fiber=x.fiber2,c.merge=x.merge2,c.ship_to=x.shipto2,c.to=x.sup2,c.status='COMP',c.size=x.size2,c.b_s=x.bs2,markdown=1,mdvalue=inventory*cost_lb_t
";
sc_exec_sql($update_warppo_sets);
echo "Dummy Records Created.";


";}}