我想在捕获异常后回滚数据,但它没有生效。
我的存储过程如下:
CREATE OR REPLACE PROCEDURE CLEAN_YQCALLSDR (
saveMonths IN INTEGER, ret OUT VARCHAR2 ) AS
BEGIN
ret := 0;
FOR rec IN (SELECT partition_name, high_value FROM user_tab_partitions WHERE table_name = 'a')
LOOP
IF to_date(substr(rec.high_value, 11, 10), 'yyyy-mm-dd') BETWEEN add_months(SYSDATE, -24) AND add_months(SYSDATE, -saveMonths) THEN
execute IMMEDIATE 'ALTER TABLE a DROP PARTITION ' || rec.partition_name;
-- Artificially created anomalies
ret := ret/0;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
-- 回滚事务
DBMS_OUTPUT.put_line('sqlcode : ' || sqlcode);
DBMS_OUTPUT.put_line('sqlerrm : ' || sqlerrm);
ret := 1;
ROLLBACK;
END;
字符串
1条答案
按热度按时间91zkwejq1#
您想回滚什么?
ALTER TABLE
?这是一个DDL,您不能将其回滚,因为它(DDL)执行commit
,