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!

Can not create dynamic SQL

ANGSHUMAN86Oct 7 2013 — edited Oct 8 2013

DECLARE

type seqarr is varray(10) of varchar2(50);
seq seqarr;
begin
seq := seqarr('SEQ_A','SEQ_B','SEQ_C','SEQ_D');
              
FOR i IN seq.FIRST .. seq.LAST
   loop
      execute immediate 'alter sequence'||seq(i)||'increment by 900000000';
      select seq(i).nextval from dual;
      execute immediate 'alter sequence'|| seq(i) ||'increment by 1 nocache';
   END LOOP;


END;

For the above code I am getting error for the 2nd statement inside loop.

ORA-06550: line 11, column 14:

PLS-00487: Invalid reference to variable 'VARCHAR2'

ORA-06550: line 11, column 14:

PL/SQL: ORA-22806: not an object or REF

ORA-06550: line 11, column 7:

PL/SQL: SQL Statement ignored

06550. 00000 -  "line %s, column %s:\n%s"

*Cause:    Usually a PL/SQL compilation error.

*Action:

This post has been answered by Frank Kulash on Oct 8 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 5 2013
Added on Oct 7 2013
6 comments
555 views