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!

Drop/Create sequence using Oracle Job Scheduler

724231Sep 25 2010 — edited Sep 25 2010
IDE for Oracle SQL Development: TOAD 9.0

Question: I am trying to do the following:

1. Check if a certain sequence exists in the user_sequences table
2. Drop the sequence if it exists
3. Re-create the same sequence afterward

All in a job that is scheduled to run daily at 12:00 AM.

What I would like to know is if this is even possible in the first place with Oracle jobs. I tried the following:

1. Create the actual "BEGIN...END" anonymous block in the job.
2. Create a procedure that uses a dynamic SQL string using the same "BEGIN...END" block that drops and recreates the sequence using the EXECUTE IMMEDIATE commands

But I have failed on all accounts. It always produces some sort of authorization error which leads me to believe that DDL statements cannot be executed using jobs, only DML statements.

BTW, by oracle jobs, I mean the SYS.DBMS_JOBS.SUBMIT object, not the job scheduler.

Please do not ask me why I need to drop and recreate the sequence. It's just a business requirement that my clients gave me. I just want to know if it can be done using jobs. If not, I would like to know if there are any work-arounds possible.

Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2010
Added on Sep 25 2010
1 comment
1,108 views