数据库版本:Oracle 11.2.0.2
场景:尝试使用过程自动创建范围分区。下面是代码。它被创建没有任何错误。但是当我执行时,它会抛出一个错误。我认为传递给变量的值不正确。我尝试了各种 sql,但没有任何效果。有人可以帮我完成这个过程。
SQL> CREATE OR REPLACE PROCEDURE MONTHLY_PARTITION as
2
3 v_partition_name varchar2(30);
4 v_limit TIMESTAMP with local time zone;
5 6 begin
7
8 select to_char(trunc(add_months(sysdate,1),'MM'),'MonYYYY')
9 into v_partition_name
10 from dual;
11
12 SELECT TO_TIMESTAMP(TO_CHAR(ADD_MONTHS(current_timestamp, 2), 'YYYYMMDD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') into v_limit from dual;
13
14 execute immediate 'ALTER TABLE TEST ADD PARTITION ' || v_partition_name || ' VALUES LESS THAN (TIMESTAMP ' || v_limit || ')';
15
16 end;
17 /
Procedure created.
SQL> show errors
No errors.
SQL>
SQL> exec MONTHLY_PARTITION;
BEGIN MONTHLY_PARTITION; END;
*
ERROR at line 1:
ORA-14019: partition bound element must be one of: string, datetime or interval literal, number, or MAXVALUE
ORA-06512: at "MONTHLY_PARTITION", line 14
ORA-06512: at line 1