日期:2014-05-17 浏览次数:20880 次
create or replace procedure P_VAC_SP_INSERT is
V_attr_id attr.attr_id%TYPE;
V_attr_value_id attr_value.attr_value_id%TYPE;
v_Errorcode Varchar2(20);
v_Errormsg Varchar2(1024);
i_Step Number;
CURSOR C_sp_code IS
SELECT party_id
FROM tmp_ldl_sp a
GROUP BY a.party_id;
begin
i_Step:=0;
dbms_output.put_line('begin');
SELECT a.attr_id
INTO V_attr_id
FROM attr a
WHERE a.attr_name LIKE '%SP Code%';
OPEN C_sp_code;
i_Step:=1;
FETCH C_sp_code INTO V_attr_value_id;
WHILE C_sp_code%FOUND LOOP
FETCH C_sp_code INTO V_attr_value_id;
dbms_output.put_line('V_attr_value_id=' || V_attr_value_id);
DBMS_OUTPUT.PUT_LINE('记录数:'|| C_sp_code %ROWCOUNT);
END LOOP;
CLOSE C_sp_code;
EXCEPTION
When Others Then
v_Errorcode := Sqlcode;
v_Errormsg := Sqlerrm;
Insert Into P_VAC_SP_INSERT_log
Values
(V_attr_value_id, i_Step, v_Errorcode, v_Errormsg, Sysdate);
Commit;
end P_VAC_SP_INSERT;
CURSOR C_sp_code IS
SELECT party_id
FROM tmp_ldl_sp a
GROUP BY a.party_id;
--group by了就把重复的剃掉了,你去掉group by 应该就和表记录数一样了。