我试图编写一个存储过程,用于在db2中删除分区后回收磁盘空间。
CREATE OR REPLACE PROCEDURE RECLAIM_PARTITION_SPACE(OUT RESPONSE_MESS
VARCHAR(200))
LANGUAGE SQL
BEGIN
DECLARE REDUCE_STOP VARCHAR(200);
DECLARE LOWER_HIGH_WATER_MARK VARCHAR(200);
DECLARE REDUCE_MAX VARCHAR(200);
DECLARE V_MSG VARCHAR(80);
DECLARE V_OUTSTATUS INTEGER DEFAULT 0;
DECLARE V_SECONDS INTEGER DEFAULT 300;
SET REDUCE_STOP = 'ALTER TABLESPACE TS_PART_TABLES REDUCE STOP';
SET LOWER_HIGH_WATER_MARK = 'ALTER TABLESPACE TS_PART_TABLES LOWER HIGH WATER MARK';
SET REDUCE_MAX = 'ALTER TABLESPACE TS_PART_TABLES REDUCE MAX';
BEGIN
EXECUTE IMMEDIATE REDUCE_STOP;
EXECUTE IMMEDIATE LOWER_HIGH_WATER_MARK;
END;
CALL DBMS_ALERT.WAITONE('wait for reduce max' , V_MSG , V_OUTSTATUS , V_SECONDS);
BEGIN
EXECUTE IMMEDIATE REDUCE_STOP;
EXECUTE IMMEDIATE REDUCE_MAX;
END;
COMMIT WORK;
END@
GRANT EXECUTE ON PROCEDURE RECLAIM_PARTITION_SPACE(VARCHAR(200)) TO
USER DB2INST1@
但是当我运行这个存储过程时,不会发生回收,但是当我手动运行查询ALTER TABLES TS_PART_TABLES LOWER HIGH WATER MARK后跟ALTER TABLES TS_PART_TABLES REDUCE MAX时,磁盘空间将被回收以用于已删除的分区。
我在存储过程中做错了什么?