roopa P, January 23, 2017 - 6:48 am UTC
Thank you for your response Chris.. it was very helpful for me...to be frank i am an ameture in pl/sql coding.
can u pls suggest how can I query high_value column to get the oldest partition.
All I want to do is to schedule the script as such it will automatically truncate the oldest partition on quarterly basis.
I have created the table using range partitioning which will create a new partition for every quarter.
roopa B, January 23, 2017 - 1:50 pm UTC
thank you chris.....your suggestion was very helpful for me...
As you said Using rownum I couldn't get the desired results...all I want to do is to schedule a job to truncate the oldest partition on quarterly basis.
I have tried to extract the date from high_value using the script
declare
l_hival varchar2(4000);
l_sql varchar2(4000);
l_high_date date;
l_cursor integer default dbms_sql.open_cursor;
l_rows_back number;
l_oldest varchar2(200);
begin
select high_value
into l_hival
from dba_tab_partitions
where table_name = 'ORDERITEM_TEMP'
and partition_position = 1;
dbms_sql.parse (l_cursor,
'begin :retval := ' || l_hival || '; end;',
dbms_sql.native);
dbms_sql.bind_variable (l_cursor, ':retval', l_high_date);
l_rows_back := dbms_sql.execute (l_cursor);
dbms_sql.variable_value (l_cursor, ':retval', l_high_date);
select to_char(l_high_date, 'yyyy-mm-dd-hh24.mi.ss') into l_oldest from dual;
end;
/
can you suggest how can I do this to all the partitions at one go and find the oldest in them.