Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, B.

Asked: May 19, 2008 - 2:08 pm UTC

Last updated: January 07, 2019 - 7:06 am UTC

Version: 10.2.0.2

Viewed 10K+ times! This question is

You Asked

Hi,

Is it possible to create Sequences within a procedure using execute immediate dynamic SQL, just as we can create other objects like table/index etc ?

If not what is the workaround for creating sequences within a procedure by executing the procedure ?

thanks
Apraim

and Tom said...

yes, it is.

Why did you not just *try it*???

Now I have to guess you did and it "did not work"

You either typed it in wrong, or maybe you got an ora-1031

http://asktom.oracle.com/Misc/RolesAndProcedures.html


ops$tkyte%ORA10GR2> grant create sequence to ops$tkyte;

Grant succeeded.

ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> create or replace procedure p
  2  as
  3  begin
  4          execute immediate 'create sequence s';
  5  end;
  6  /

Procedure created.

ops$tkyte%ORA10GR2> exec p

PL/SQL procedure successfully completed.

ops$tkyte%ORA10GR2> select s.nextval from dual;

   NEXTVAL
----------
         1

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

B Apraim, May 20, 2008 - 12:44 pm UTC

thanks Tom.

I guess 'Create Sequence' privilge might have been missing.

Christian




Angel, May 20, 2008 - 1:12 pm UTC

thanks
Angel

Thanks

Swapnil, January 07, 2019 - 6:26 am UTC

Given url may be expired..

Connor McDonald
January 07, 2019 - 7:05 am UTC

Thanks - that's a typo that we'll fix

More to Explore

Security

All of the vital components for a secure database are covered in the Security guide.