Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating procedure to purge recyclebin for a user

3040542Jul 14 2016 — edited Jul 14 2016

I am trying to get a proc to work. Any help appreciated.

The plan is to be able to run it like so:

exec MY_PURGE_RECYCLEBIN(‘30’)     --  To take a parameter e.g 30 for the last 30 days to purge

create or replace

procedure  MY_PURGE_RECYCLEBIN (days IN number)

IS

BEGIN

FOR r1 IN (select 'purge table '|| owner ||'.'|| object_name ||'') AS v_sql

from dba_recyclebin

where can_purge = 'YES'

and type = 'TABLE'

and owner = 'USER01'

and to_date(droptime,'YYYY-MM-DD:HH24:MI:SS') < sysdate - days);

LOOP

    EXECUTE IMMEDIATE r1.v_sql;

  END LOOP;

END;

/

Cheers

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 11 2016
Added on Jul 14 2016
13 comments
1,169 views