PHP code: open c1 for Que_Sql; loop fetch c1 into p_empid; exit when c1%notfound; select name into p_name from tb_employee where employee_id=p_empid; insert into tmp_2 select p_empid,p_name, sum(decode(time,'01',ct,0)),sum(decode(time,'02',ct,0)),sum(decode(time,'30',ct,0)),sum(decode(time,'31',ct,0)),sum(decode(time,'tt',ct,0)),p_seq1 from tmp_1 where employee_id=p_empid group by employee_id; end loop;
open c1 for Que_Sql; loop fetch c1 into p_empid; exit when c1%notfound; select name into p_name from tb_employee where employee_id=p_empid; insert into tmp_2 select p_empid,p_name, sum(decode(time,'01',ct,0)),sum(decode(time,'02',ct,0)),sum(decode(time,'30',ct,0)),sum(decode(time,'31',ct,0)),sum(decode(time,'tt',ct,0)),p_seq1 from tmp_1 where employee_id=p_empid group by employee_id; end loop;
PHP code: insert into tmp_2 select p_empid,p_name, sum(decode(time,'01',ct,0)),sum(decode(time,'02',ct,0)),sum(decode(time,'30',ct,0)),sum(decode(time,'31',ct,0)),sum(decode(time,'tt',ct,0)),p_seq1 from tmp_1 where employee_id=p_empid group by employee_id;
insert into tmp_2 select p_empid,p_name, sum(decode(time,'01',ct,0)),sum(decode(time,'02',ct,0)),sum(decode(time,'30',ct,0)),sum(decode(time,'31',ct,0)),sum(decode(time,'tt',ct,0)),p_seq1 from tmp_1 where employee_id=p_empid group by employee_id;