huawei--循环,SQL%ROWCOUNT为0控制结束


CREATE OR REPLACE PROCEDURE p_maintendata
AS
v_rowcount NUMBER(20);
BEGIN 
  LOOP
  DELETE FROM tInnoCallStatInfo
  WHERE STATISTICSTARTTIME < SYSDATE - 3
  AND ROWNUM <= 2000;  
  v_rowcount := SQL%ROWCOUNT;
  COMMIT;
  EXIT WHEN v_rowcount = 0;
  END LOOP;
EXCEPTION
  WHEN OTHERS THEN
  ROLLBACK;
  RETURN;
END p_maintendata;
/

你可能感兴趣的:(数据库-存储过程,数据库-函数,sql,delete)