Hi lads
I’m trying to automatize a partitioning process here, and well ren into something odd.
Why wouldnt’the following work?
create table flp_aa (cdate date, value varchar2(255))
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64M
)
LOGGING
PARTITION BY RANGE (cdate)
(
PARTITION flp_aa_1010 VALUES LESS THAN (last_day(to_date('20101101', 'YYYYMMDD')))
NOLOGGING
NOCOMPRESS
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64M
NEXT 512K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
)
The idea is to use last_day(to_date('20101101', 'YYYYMMDD')) so each pretty partition ends on the last day of that month and everybody is happy. However I get an ORA-14019 when trying to execute that code…
[UPDATE]
Darn odd:
This work:
(...)
PARTITION flp_aa_1010 VALUES LESS THAN (to_date('20101101', 'YYYYMMDD'))
(...)
This doesn’t work:
(...)
PARTITION flp_aa_1010 VALUES LESS THAN (last_day(to_date('20101101', 'YYYYMMDD')))
(...)
And this does not again:
(...)
PPARTITION flp_aa_1010 VALUES LESS THAN to_date(last_day(to_date('201010','YYYYMM'))))
(...)
What the duck? which class did I miss here?
Isn’t the output of all these functions the same?
could anyone enlighten me?
cheers
f.
As the link you posted says:
A function call (LAST_DAY) is not a string, datetime or interval
literal, number, or MAXVALUE. True, TO_DATE is a function call, but this is allowed as an exception because traditionally it was the only way to generate a DATE literal (you can now use the ANSI format DATE ‘2010-11-26’ but not a lot of people know that). See documentation.
However, at the point where you generate the value ‘20101101’, you could apply LAST_DAY and use the result instead of that – something like: