坑来了,使用该方法编写存储过程删除30天以前的旧分区:
create or replace procedure pd01.deltestdata_new(v_keep_days NUMBER DEFAULT 30) Authid CURRENT_USER
is
v_date date;
v_part_number number;
begin
v_date := sysdate - v_keep_days;
select count(partition_name) into v_part_number from all_tab_partitions where table_owner='PD01' and table_name='PD_TESTDATA';
if v_part_number >= v_keep_days then
execute immediate 'ALTER TABLE PD01.PD_TESTDATA DROP PARTITION FOR('||v_date||')';
select count(partition_name) into v_part_number from all_tab_partitions where table_owner='PD01' and table_name='PD_TESTDATA';
insert into pdms01.del_testdata_log(exec_time,dropped_partition_date,remain_partition_number) values(sysdate,to_char(v_date),v_part_number);
commit;
else
insert into pdms01.del_testdata_log(exec_time,dropped_partition_date,remain_partition_number) values(sysdate,'none',v_part_number);
commit;
end if;
end;
/
exec pdms01.deltestdata_new; -------------竟然报错。。。
ORA-14763: 无法将 FOR VALUES 子句解析为分区编号
ORA-06512: 在 "PDMS01.TEST11", line 7
ORA-06512: 在 line 1